@@ -994,6 +994,10 @@ func fetchDoHServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isN
994994 body := dohTestPacket (0xcafe ).Data
995995 useGet := false
996996 if _ , _ , _ , _ , err := proxy .xTransport .DoHQuery (useGet , url , body , proxy .timeout ); err != nil {
997+ if errors .Is (err , errCertHashNotFound ) {
998+ dlog .Criticalf ("[%s] Certificate hash %x not found" , name , stamp .Hashes )
999+ return ServerInfo {}, err
1000+ }
9971001 useGet = true
9981002 if _ , _ , _ , _ , err := proxy .xTransport .DoHQuery (useGet , url , body , proxy .timeout ); err != nil {
9991003 return ServerInfo {}, err
@@ -1029,31 +1033,17 @@ func fetchDoHServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isN
10291033 }
10301034 dlog .Infof ("[%s] TLS version: %x - Protocol: %v - Cipher suite: %v" , name , tls .Version , protocol , tls .CipherSuite )
10311035 showCerts := proxy .showCerts
1032- found := false
1033- var wantedHash [32 ]byte
10341036 for _ , cert := range tls .PeerCertificates {
10351037 h := sha256 .Sum256 (cert .RawTBSCertificate )
10361038 if showCerts {
10371039 dlog .Noticef ("Advertised cert: [%s] [%x]" , cert .Subject , h )
10381040 } else {
10391041 dlog .Debugf ("Advertised cert: [%s] [%x]" , cert .Subject , h )
10401042 }
1041- for _ , hash := range stamp .Hashes {
1042- if len (hash ) == len (wantedHash ) {
1043- copy (wantedHash [:], hash )
1044- if h == wantedHash {
1045- found = true
1046- break
1047- }
1048- }
1049- }
1050- if found {
1051- break
1052- }
10531043 }
1054- if ! found && len (stamp .Hashes ) > 0 {
1055- dlog .Criticalf ("[%s] Certificate hash [%x] not found" , name , wantedHash )
1056- return ServerInfo {}, fmt . Errorf ( "Certificate hash not found" )
1044+ if len (stamp .Hashes ) > 0 && ! certHashesMatch ( tls , stamp . Hashes ) {
1045+ dlog .Criticalf ("[%s] Certificate hash %x not found" , name , stamp . Hashes )
1046+ return ServerInfo {}, errCertHashNotFound
10571047 }
10581048 if len (serverResponse ) < MinDNSPacketSize || len (serverResponse ) > MaxDNSPacketSize ||
10591049 serverResponse [0 ] != 0xca || serverResponse [1 ] != 0xfe || serverResponse [4 ] != 0x00 || serverResponse [5 ] != 0x01 {
0 commit comments