log.Fatalln(err)
}
refreshPasswd()
- if *pypiCertHash == "" {
- pypiHTTPTransport = http.Transport{}
- } else {
+ tlsConfig := tls.Config{
+ ClientSessionCache: tls.NewLRUClientSessionCache(16),
+ NextProtos: []string{"h2", "http/1.1"},
+ }
+ pypiHTTPTransport = http.Transport{
+ ForceAttemptHTTP2: true,
+ TLSClientConfig: &tlsConfig,
+ }
+ if *pypiCertHash != "" {
ourDgst, err := hex.DecodeString(*pypiCertHash)
if err != nil {
log.Fatalln(err)
}
- pypiHTTPTransport = http.Transport{
- TLSClientConfig: &tls.Config{
- VerifyConnection: func(s tls.ConnectionState) error {
- spki := s.VerifiedChains[0][0].RawSubjectPublicKeyInfo
- theirDgst := sha256.Sum256(spki)
- if bytes.Compare(ourDgst, theirDgst[:]) != 0 {
- return errors.New("certificate's digest mismatch")
- }
- return nil
- }},
+ tlsConfig.VerifyConnection = func(s tls.ConnectionState) error {
+ spki := s.VerifiedChains[0][0].RawSubjectPublicKeyInfo
+ theirDgst := sha256.Sum256(spki)
+ if bytes.Compare(ourDgst, theirDgst[:]) != 0 {
+ return errors.New("certificate's SPKI digest mismatch")
+ }
+ return nil
}
}