mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-02 06:38:36 +00:00
Fix public key verification with empty certificate chain
This commit is contained in:
@@ -473,6 +473,7 @@ func NewSTDServer(ctx context.Context, logger log.ContextLogger, options option.
|
||||
}
|
||||
tlsConfig.ClientCAs = clientCertificateCA
|
||||
} else if len(options.ClientCertificatePublicKeySHA256) > 0 {
|
||||
verifyIfGiven := tlsConfig.ClientAuth == tls.VerifyClientCertIfGiven
|
||||
switch tlsConfig.ClientAuth {
|
||||
case tls.RequireAndVerifyClientCert:
|
||||
tlsConfig.ClientAuth = tls.RequireAnyClientCert
|
||||
@@ -480,6 +481,9 @@ func NewSTDServer(ctx context.Context, logger log.ContextLogger, options option.
|
||||
tlsConfig.ClientAuth = tls.RequestClientCert
|
||||
}
|
||||
tlsConfig.VerifyPeerCertificate = func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
|
||||
if verifyIfGiven && len(rawCerts) == 0 {
|
||||
return nil
|
||||
}
|
||||
return VerifyPublicKeySHA256(options.ClientCertificatePublicKeySHA256, rawCerts)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user