Skip to content

Commit 2005f73

Browse files
committed
chore: upgrade golangci-lint and config
Also adds some clarifying documentation for usage of deprecated PEM encryption methods.
1 parent a866575 commit 2005f73

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
- name: golangci-lint
1111
uses: golangci/golangci-lint-action@v2
1212
with:
13-
version: v1.41.1
13+
version: v1.43.0

.golangci.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
run:
2+
timeout: 10m
3+
issues-exit-code: 0
4+
tests: false
5+
allow-parallel-runners: true
6+
7+
issues:
8+
exclude-use-default: false

certificate.go

+3
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,18 @@ func ParseCertificateFromPEMBytes(pemBytes []byte) (*x509.Certificate, error) {
5252
// Will return ErrCertificateMustBePEMEncoded if the given byte array is not a valid PEM block, or
5353
// ErrUnknownEncryption if the byte array was encrypted in an unknown format, or not encrypted
5454
// at all.
55+
// Note: Usage of RFC 1423 encrypted PEM blocks is deprecated since Go 1.16!
5556
func ParseCertificateFromEncryptedPEMBytes(pemBytes []byte, password []byte) (*x509.Certificate, error) {
5657
var block *pem.Block
5758
if block, _ = pem.Decode(pemBytes); block == nil {
5859
return nil, ErrCertificateMustBePEMEncoded
5960
}
6061

6162
var blockDecrypted []byte
63+
// nolint: staticcheck: Just passing through - deprecation is communicated in function signature
6264
if x509.IsEncryptedPEMBlock(block) {
6365
var err error
66+
// nolint: staticcheck
6467
if blockDecrypted, err = x509.DecryptPEMBlock(block, password); err != nil {
6568
return nil, err
6669
}

privatekey.go

+3
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,18 @@ func ParsePrivateKeyFromPEMBytes(pemBytes []byte) (crypto.PrivateKey, error) {
5959
// Will return ErrKeyMustBePEMEncoded if the given byte array is not a valid PEM block, or
6060
// ErrUnknownEncryption if the byte array was encrypted in an unknown format, or not encrypted
6161
// at all.
62+
// Note: Usage of RFC 1423 encrypted PEM blocks is deprecated since Go 1.16! Use PKCS #8 instead.
6263
func ParsePrivateKeyFromEncryptedPEMBytes(pemBytes []byte, password []byte) (crypto.PrivateKey, error) {
6364
var block *pem.Block
6465
if block, _ = pem.Decode(pemBytes); block == nil {
6566
return nil, ErrKeyMustBePEMEncoded
6667
}
6768

6869
var blockDecrypted []byte
70+
// nolint: staticcheck: Just passing through - deprecation is communicated in function signature
6971
if x509.IsEncryptedPEMBlock(block) {
7072
var err error
73+
// nolint: staticcheck
7174
if blockDecrypted, err = x509.DecryptPEMBlock(block, password); err != nil {
7275
return nil, err
7376
}

publickey.go

+3
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@ func ParsePublicKeyFromPEMBytes(pemBytes []byte) (crypto.PublicKey, error) {
5050
// Will return ErrKeyMustBePEMEncoded if the given byte array is not a valid PEM block, or
5151
// ErrUnknownEncryption if the byte array was encrypted in an unknown format, or not encrypted
5252
// at all.
53+
// Note: Usage of RFC 1423 encrypted PEM blocks is deprecated since Go 1.16!
5354
func ParsePublicKeyFromEncryptedPEMBytes(pemBytes []byte, password []byte) (crypto.PublicKey, error) {
5455
var block *pem.Block
5556
if block, _ = pem.Decode(pemBytes); block == nil {
5657
return nil, ErrKeyMustBePEMEncoded
5758
}
5859

5960
var blockDecrypted []byte
61+
// nolint: staticcheck: Just passing through - deprecation is communicated in function signature
6062
if x509.IsEncryptedPEMBlock(block) {
6163
var err error
64+
// nolint: staticcheck
6265
if blockDecrypted, err = x509.DecryptPEMBlock(block, password); err != nil {
6366
return nil, err
6467
}

0 commit comments

Comments
 (0)