Go 1.25 disabled SHA-1 signature algorithms in TLS 1.2 according to RFC 9155.
The default can be reverted using the `tlssha1=1` setting.
+Go 1.25 switched to SHA-256 to fill in missing SubjectKeyId in
+crypto/x509.CreateCertificate. The setting `x509sha256skid=0` reverts to SHA-1.
+
Go 1.25 corrected the semantics of contention reports for runtime-internal locks,
and so removed the [`runtimecontentionstacks` setting](/pkg/runtime#hdr-Environment_Variable).
--- /dev/null
+[CreateCertificate] now uses truncated SHA-256 to populate the `SubjectKeyId` if
+it is missing. The GODEBUG setting `x509sha256skid=0` reverts to SHA-1.
"crypto/elliptic"
"crypto/rsa"
"crypto/sha1"
+ "crypto/sha256"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/pem"
subjectKeyId := template.SubjectKeyId
if len(subjectKeyId) == 0 && template.IsCA {
- // SubjectKeyId generated using method 1 in RFC 5280, Section 4.2.1.2:
- // (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the
- // value of the BIT STRING subjectPublicKey (excluding the tag,
- // length, and number of unused bits).
- h := sha1.Sum(publicKeyBytes)
- subjectKeyId = h[:]
+ if x509sha256skid.Value() == "0" {
+ x509sha256skid.IncNonDefault()
+ // SubjectKeyId generated using method 1 in RFC 5280, Section 4.2.1.2:
+ // (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the
+ // value of the BIT STRING subjectPublicKey (excluding the tag,
+ // length, and number of unused bits).
+ h := sha1.Sum(publicKeyBytes)
+ subjectKeyId = h[:]
+ } else {
+ // SubjectKeyId generated using method 1 in RFC 7093, Section 2:
+ // 1) The keyIdentifier is composed of the leftmost 160-bits of the
+ // SHA-256 hash of the value of the BIT STRING subjectPublicKey
+ // (excluding the tag, length, and number of unused bits).
+ h := sha256.Sum256(publicKeyBytes)
+ subjectKeyId = h[:20]
+ }
}
// Check that the signer's public key matches the private key, if available.
})
}
+var x509sha256skid = godebug.New("x509sha256skid")
+
// pemCRLPrefix is the magic string that indicates that we have a PEM encoded
// CRL.
var pemCRLPrefix = []byte("-----BEGIN X509 CRL")
{Name: "x509keypairleaf", Package: "crypto/tls", Changed: 23, Old: "0"},
{Name: "x509negativeserial", Package: "crypto/x509", Changed: 23, Old: "1"},
{Name: "x509rsacrt", Package: "crypto/x509", Changed: 24, Old: "0"},
+ {Name: "x509sha256skid", Package: "crypto/x509", Changed: 25, Old: "0"},
{Name: "x509usefallbackroots", Package: "crypto/x509"},
{Name: "x509usepolicies", Package: "crypto/x509", Changed: 24, Old: "0"},
{Name: "zipinsecurepath", Package: "archive/zip"},
The number of non-default behaviors executed by the crypto/x509
package due to a non-default GODEBUG=x509rsacrt=... setting.
+ /godebug/non-default-behavior/x509sha256skid:events
+ The number of non-default behaviors executed by the crypto/x509
+ package due to a non-default GODEBUG=x509sha256skid=... setting.
+
/godebug/non-default-behavior/x509usefallbackroots:events
The number of non-default behaviors executed by the crypto/x509
package due to a non-default GODEBUG=x509usefallbackroots=...