Debian Codegraph @

transports/webtunnel/utls.go

raw symbols SCIP
1 package webtunnelscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/
2
3 import (
4 "crypto/hmacscip-go gomod github.com/golang/go/src go1.22.0 `crypto/hmac`/"
5 "crypto/x509scip-go gomod github.com/golang/go/src go1.22.0 `crypto/x509`/"
6 "errorsscip-go gomod github.com/golang/go/src go1.22.0 errors/"
7 "netscip-go gomod github.com/golang/go/src go1.22.0 net/"
8
9 utlsscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/ "github.com/refraction-networking/utlsscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/"
10 "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel/common/certiChainHashCalcscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel aab00213ba56 `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel/common/certiChainHashCalc`/"
11
12 "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/common/utlsutilscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/common/utlsutil`/"
13 )
14
15 type uTLSConfigscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig# struct {
16 ServerNamescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#ServerName. string
17
18 uTLSFingerprintscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#uTLSFingerprint. string
19
20 // allowInsecure is used to skip certificate verification.
21 // This setting should not be used unless pinnedPeerCertificateChainSha256
22 // is set, otherwise it will allow any certificate to be accepted.
23 allowInsecurescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#allowInsecure. bool
24 pinnedPeerCertificateChainSha256scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#pinnedPeerCertificateChainSha256. [][]byte
25
26 InsecureServerNameToVerifyscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#InsecureServerNameToVerify. string
27 }
28
29 func newUTLSTransportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/newUTLSTransport().(config *uTLSConfigscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#) (uTLSTransportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#, error) {
30 return uTLSTransportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#{kindscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#kind.: "utls",
31 serverNamescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#serverName.: config.ServerNamescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#ServerName.,
32 uTLSFingerprintscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#uTLSFingerprint.: config.uTLSFingerprintscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#uTLSFingerprint.,
33 allowInsecurescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#allowInsecure.: config.allowInsecurescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#allowInsecure.,
34 pinnedPeerCertificateChainSha256scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#pinnedPeerCertificateChainSha256.: config.pinnedPeerCertificateChainSha256scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#pinnedPeerCertificateChainSha256.,
35 InsecureServerNameToVerifyscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#InsecureServerNameToVerify.: config.InsecureServerNameToVerifyscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSConfig#InsecureServerNameToVerify.,
36 }, nil
37 }
38
39 type uTLSTransportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport# struct {
40 kindscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#kind. string
41 serverNamescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#serverName. string
42
43 uTLSFingerprintscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#uTLSFingerprint. string
44
45 allowInsecurescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#allowInsecure. bool
46 pinnedPeerCertificateChainSha256scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#pinnedPeerCertificateChainSha256. [][]byte
47
48 InsecureServerNameToVerifyscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#InsecureServerNameToVerify. string
49 }
50
51 func (t *uTLSTransportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#) Clientscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#Client().(conn netscip-go gomod github.com/golang/go/src go1.22.0 net/.Connscip-go gomod github.com/golang/go/src go1.22.0 net/Conn#) (netscip-go gomod github.com/golang/go/src go1.22.0 net/.Connscip-go gomod github.com/golang/go/src go1.22.0 net/Conn#, error) {
52 switch t.kindscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#kind. {
53 case "utls":
54 fp, err := utlsutilscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/common/utlsutil`/.ParseClientHelloIDscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/common/utlsutil`/ParseClientHelloID().(t.uTLSFingerprintscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#uTLSFingerprint.)
55 if err != nil {
56 return nil, err
57 }
58 if t.allowInsecurescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#allowInsecure. && t.pinnedPeerCertificateChainSha256scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#pinnedPeerCertificateChainSha256. == nil {
59 return nil, errorsscip-go gomod github.com/golang/go/src go1.22.0 errors/.Newscip-go gomod github.com/golang/go/src go1.22.0 errors/New().("naked allowInsecure is not allowed, pinnedPeerCertificateChainSha256 must be set to verify remote certificate chain")
60 }
61 conf := &utlsscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/.Configscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/Config#{ServerNamescip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/Config#ServerName.: t.serverNamescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#serverName.,
62 InsecureSkipVerifyscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/Config#InsecureSkipVerify.: t.allowInsecurescip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#allowInsecure.,
63 VerifyPeerCertificatescip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/Config#VerifyPeerCertificate.: t.verifyPeerCertscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#verifyPeerCert().,
64 InsecureServerNameToVerifyscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/Config#InsecureServerNameToVerify.: t.InsecureServerNameToVerifyscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#InsecureServerNameToVerify.}
65 return utlsscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/.UClientscip-go gomod gitlab.torproject.org/shelikhoo/utls-temporary 0f042ad603ef `github.com/refraction-networking/utls`/UClient().(conn, conf, *fp), nil
66 }
67 return nil, errorsscip-go gomod github.com/golang/go/src go1.22.0 errors/.Newscip-go gomod github.com/golang/go/src go1.22.0 errors/New().("unknown kind")
68 }
69
70 func (t *uTLSTransportscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#) verifyPeerCertscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#verifyPeerCert().(rawCerts [][]byte, verifiedChains [][]*x509scip-go gomod github.com/golang/go/src go1.22.0 `crypto/x509`/.Certificatescip-go gomod github.com/golang/go/src go1.22.0 `crypto/x509`/Certificate#) error {
71 if t.pinnedPeerCertificateChainSha256scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#pinnedPeerCertificateChainSha256. != nil {
72 hashValue := certiChainHashCalcscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel aab00213ba56 `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel/common/certiChainHashCalc`/.GenerateCertChainHashscip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel aab00213ba56 `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/webtunnel/common/certiChainHashCalc`/GenerateCertChainHash().(rawCerts)
73 for _, v := range t.pinnedPeerCertificateChainSha256scip-go gomod gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird . `gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/transports/webtunnel`/uTLSTransport#pinnedPeerCertificateChainSha256. {
74 if hmacscip-go gomod github.com/golang/go/src go1.22.0 `crypto/hmac`/.Equalscip-go gomod github.com/golang/go/src go1.22.0 `crypto/hmac`/Equal().(hashValue, v) {
75 return nil
76 }
77 }
78 return errorsscip-go gomod github.com/golang/go/src go1.22.0 errors/.Newscip-go gomod github.com/golang/go/src go1.22.0 errors/New().("pinned certificate chain hash not matched")
79 }
80 return nil
81 }