Skip to content

Commit 13cfe5d

Browse files
author
Andrew Mitchell
committed
Resolves some linting errors flagged in GitHub actions
1 parent 6aa62fb commit 13cfe5d

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

client/client.go

+3
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ func (c *Client) LoadTLSCertificate(server, certFile string) (cert tls.Certifica
388388
return cert, nil
389389
}
390390

391+
// DefaultLoadPubKey will parse a public key from the provided bytes.
392+
// The function used to load the public key in ScanDir if no LoadPubKey
393+
// argument is provided
391394
func DefaultLoadPubKey(in []byte) (crypto.PublicKey, error) {
392395
block, _ := pem.Decode(in)
393396
if block == nil {

client/keys.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,13 @@ func signOpFromSignerOpts(key *PrivateKey, opts crypto.SignerOpts) protocol.Op {
6666
case *rsa.PublicKey:
6767
if value, ok := rsaCrypto[opts.HashFunc()]; ok {
6868
return value
69-
} else {
70-
return protocol.OpError
7169
}
70+
return protocol.OpError
7271
case *ecdsa.PublicKey:
7372
if value, ok := ecdsaCrypto[opts.HashFunc()]; ok {
7473
return value
75-
} else {
76-
return protocol.OpError
7774
}
75+
return protocol.OpError
7876
case ed25519.PublicKey:
7977
return protocol.OpEd25519Sign
8078
default:

cmd/gokeyless/gokeyless.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func runMain() error {
240240

241241
return nil
242242
case manualMode && configMode:
243-
return fmt.Errorf("can't specify both --manual-activation and --config-only!")
243+
return fmt.Errorf("can't specify both --manual-activation and --config-only")
244244
case manualMode:
245245
// Allow manual activation (requires the CSR to be manually signed).
246246
// manual activation won't proceed to start the server
@@ -403,15 +403,15 @@ func validCertExpiry(cert *x509.Certificate) bool {
403403
}
404404

405405
// needNewCertAndKey checks the validity of certificate and key
406-
func (config Config) needNewCertAndKey() bool {
407-
_, err := tls.LoadX509KeyPair(config.CertFile, config.KeyFile)
406+
func (c Config) needNewCertAndKey() bool {
407+
_, err := tls.LoadX509KeyPair(c.CertFile, c.KeyFile)
408408
if err != nil {
409409
log.Errorf("cannot load server cert/key: %v", err)
410410
return true
411411
}
412412

413413
// error is ignore because tls.LoadX509KeyPair already verify the existence of the file
414-
certBytes, _ := os.ReadFile(config.CertFile)
414+
certBytes, _ := os.ReadFile(c.CertFile)
415415
// error is ignore because tls.LoadX509KeyPair already verify the file can be parsed
416416
cert, _ := helpers.ParseCertificatePEM(certBytes)
417417
// verify the leaf certificate
@@ -424,8 +424,8 @@ func (config Config) needNewCertAndKey() bool {
424424
}
425425

426426
// verifyCSRAndKey checks if csr and key files exist and if they match
427-
func (config Config) verifyCSRAndKey() bool {
428-
csrBytes, err := os.ReadFile(config.CSRFile)
427+
func (c Config) verifyCSRAndKey() bool {
428+
csrBytes, err := os.ReadFile(c.CSRFile)
429429
if err != nil {
430430
log.Errorf("cannot read csr file: %v", err)
431431
return false
@@ -448,7 +448,7 @@ func (config Config) verifyCSRAndKey() bool {
448448
return false
449449
}
450450

451-
keyBytes, err := os.ReadFile(config.KeyFile)
451+
keyBytes, err := os.ReadFile(c.KeyFile)
452452
if err != nil {
453453
log.Errorf("cannot read private key file: %v", err)
454454
return false

internal/test/params/params.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ var (
6565
// Compatibility. Before running tests, copy the contents of the
6666
// testdata/tokens/ directory to your SoftHSM2 token directory, usually
6767
// located at /var/lib/softhsm/tokens/, and run `make test-softhsm`
68-
RSAURI = "pkcs11:token=SoftHSM2%20Token;id=%03?module-path=" + getSoftHSMModulePath() + "&pin-value=1234"
68+
RSAURI = "pkcs11:token=SoftHSM2%20Token;id=%03?module-path=" + getSoftHSMModulePath() + "&pin-value=1234"
69+
// ECDSAURI is a sample PKCS #11 URIs used for testing HSM Compatibility
6970
ECDSAURI = "pkcs11:token=SoftHSM2%20Token;id=%02?module-path=" + getSoftHSMModulePath() + "&pin-value=1234"
7071
)
7172

0 commit comments

Comments
 (0)