crypto/tls: consistently use testenv.SetGODEBUG in tests

Change-Id: I13794baf4ae086d553b78031ff93b1d46a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/776704
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
This commit is contained in:
Filippo Valsorda 2026-05-09 19:37:56 +02:00 committed by Gopher Robot
parent 9578a80f15
commit aca2bff284
3 changed files with 5 additions and 4 deletions

View file

@ -40,7 +40,7 @@ func TestGenerateCertificates(t *testing.T) {
}
// Allow RSA keys below 1024 bits for testRSA512.
t.Setenv("GODEBUG", os.Getenv("GODEBUG")+",rsa1024min=0")
testenv.SetGODEBUG(t, "rsa1024min=0")
cryptotest.SetGlobalRandom(t, 0)

View file

@ -17,6 +17,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"internal/testenv"
"io"
"net"
"os"
@ -1773,7 +1774,7 @@ func expectError(t *testing.T, err error, sub string) {
}
func TestKeyTooSmallForRSAPSS(t *testing.T) {
t.Setenv("GODEBUG", os.Getenv("GODEBUG")+",rsa1024min=0")
testenv.SetGODEBUG(t, "rsa1024min=0")
clientConn, serverConn := localPipe(t)
client := Client(clientConn, testConfigClient.Clone())
done := make(chan struct{})

View file

@ -2208,7 +2208,7 @@ func TestX509KeyPairPopulateCertificate(t *testing.T) {
certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER})
t.Run("x509keypairleaf=0", func(t *testing.T) {
t.Setenv("GODEBUG", "x509keypairleaf=0")
testenv.SetGODEBUG(t, "x509keypairleaf=0")
cert, err := X509KeyPair(certPEM, keyPEM)
if err != nil {
t.Fatal(err)
@ -2218,7 +2218,7 @@ func TestX509KeyPairPopulateCertificate(t *testing.T) {
}
})
t.Run("x509keypairleaf=1", func(t *testing.T) {
t.Setenv("GODEBUG", "x509keypairleaf=1")
testenv.SetGODEBUG(t, "x509keypairleaf=1")
cert, err := X509KeyPair(certPEM, keyPEM)
if err != nil {
t.Fatal(err)