mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Fix SHA1 patch for Go 1.19.4; patch test (#18405)
Bad news: the hot patch we were using breaks in Go 1.19.4: 6109c07ec4
Good news: we can now patch with an environment variable at runtime.
Co-authored-by: Christopher Swenson <christopher.swenson@hashicorp.com>
This commit is contained in:
@@ -12,8 +12,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/hashicorp/vault/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
internal.PatchSha1()
|
||||||
|
}
|
||||||
|
|
||||||
// SignedData is an opaque data structure for creating signed data payloads
|
// SignedData is an opaque data structure for creating signed data payloads
|
||||||
type SignedData struct {
|
type SignedData struct {
|
||||||
sd signedData
|
sd signedData
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ var debugAllowSHA1 bool
|
|||||||
// TODO: remove when Vault <=1.11 is no longer supported
|
// TODO: remove when Vault <=1.11 is no longer supported
|
||||||
func PatchSha1() {
|
func PatchSha1() {
|
||||||
patchSha1.Do(func() {
|
patchSha1.Do(func() {
|
||||||
|
// for Go 1.19.4 and later
|
||||||
|
godebug := os.Getenv("GODEBUG")
|
||||||
|
if godebug != "" {
|
||||||
|
godebug += ","
|
||||||
|
}
|
||||||
|
godebug += "x509sha1=1"
|
||||||
|
os.Setenv("GODEBUG", godebug)
|
||||||
|
|
||||||
|
// for Go 1.19.3 and earlier, patch the variable
|
||||||
patchBefore, err := goversion.NewSemver(sha1PatchVersionsBefore)
|
patchBefore, err := goversion.NewSemver(sha1PatchVersionsBefore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user