Skip to content

Commit 2688f25

Browse files
committed
cli/context: ignore linting warnings about RFC 1423 encryption
From https://go-review.googlesource.com/c/go/+/264159 > It's unfortunate that we don't implement PKCS#8 encryption so we can't > recommend an alternative but PEM encryption is so broken that it's worth > deprecating outright. When linting on Go 1.16: cli/context/docker/load.go:69:6: SA1019: x509.IsEncryptedPEMBlock is deprecated: Legacy PEM encryption as specified in RFC 1423 is insecure by design. Since it does not authenticate the ciphertext, it is vulnerable to padding oracle attacks that can let an attacker recover the plaintext. (staticcheck) if x509.IsEncryptedPEMBlock(pemBlock) { ^ cli/context/docker/load.go:70:20: SA1019: x509.DecryptPEMBlock is deprecated: Legacy PEM encryption as specified in RFC 1423 is insecure by design. Since it does not authenticate the ciphertext, it is vulnerable to padding oracle attacks that can let an attacker recover the plaintext. (staticcheck) keyBytes, err = x509.DecryptPEMBlock(pemBlock, []byte(c.TLSPassword)) ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 2776a6d commit 2688f25

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

cli/context/docker/load.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ func (c *Endpoint) tlsConfig() (*tls.Config, error) {
6666
}
6767

6868
var err error
69-
if x509.IsEncryptedPEMBlock(pemBlock) {
70-
keyBytes, err = x509.DecryptPEMBlock(pemBlock, []byte(c.TLSPassword))
69+
// TODO should we follow Golang, and deprecate RFC 1423 encryption, and produce a warning (or just error)? see https://github.com/docker/cli/issues/3212
70+
if x509.IsEncryptedPEMBlock(pemBlock) { //nolint: staticcheck // SA1019: x509.IsEncryptedPEMBlock is deprecated, and insecure by design
71+
keyBytes, err = x509.DecryptPEMBlock(pemBlock, []byte(c.TLSPassword)) //nolint: staticcheck // SA1019: x509.IsEncryptedPEMBlock is deprecated, and insecure by design
7172
if err != nil {
7273
return nil, errors.Wrap(err, "private key is encrypted, but could not decrypt it")
7374
}

0 commit comments

Comments
 (0)