Skip to content

Commit 50f8789

Browse files
authored
Merge pull request #1304 from testwill/master
2 parents 68e04e2 + 5e37590 commit 50f8789

File tree

7 files changed

+16
-36
lines changed

7 files changed

+16
-36
lines changed

bundler/bundler.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,7 @@ func isSelfSigned(cert *x509.Certificate) bool {
399399
}
400400

401401
func isChainRootNode(cert *x509.Certificate) bool {
402-
if isSelfSigned(cert) {
403-
return true
404-
}
405-
return false
402+
return isSelfSigned(cert)
406403
}
407404

408405
func (b *Bundler) verifyChain(chain []*fetchedIntermediate) bool {

config/config.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/cloudflare/cfssl/helpers"
2020
"github.com/cloudflare/cfssl/log"
2121
ocspConfig "github.com/cloudflare/cfssl/ocsp/config"
22+
2223
// empty import of zlint/v3 required to have lints registered.
2324
_ "github.com/zmap/zlint/v3"
2425
"github.com/zmap/zlint/v3/lint"
@@ -296,7 +297,7 @@ func (p *SigningProfile) populate(cfg *Config) error {
296297

297298
if p.AuthRemote.AuthKeyName != "" {
298299
log.Debug("match auth remote key in profile to auth_keys section")
299-
if key, ok := cfg.AuthKeys[p.AuthRemote.AuthKeyName]; ok == true {
300+
if key, ok := cfg.AuthKeys[p.AuthRemote.AuthKeyName]; ok {
300301
if key.Type == "standard" {
301302
p.RemoteProvider, err = auth.New(key.Key, nil)
302303
if err != nil {
@@ -441,11 +442,7 @@ func (p *Signing) NeedsRemoteSigner() bool {
441442
}
442443
}
443444

444-
if p.Default.RemoteServer != "" {
445-
return true
446-
}
447-
448-
return false
445+
return p.Default.RemoteServer != ""
449446
}
450447

451448
// NeedsLocalSigner returns true if one of the profiles doe not have a remote set
@@ -456,11 +453,7 @@ func (p *Signing) NeedsLocalSigner() bool {
456453
}
457454
}
458455

459-
if p.Default.RemoteServer == "" {
460-
return true
461-
}
462-
463-
return false
456+
return p.Default.RemoteServer == ""
464457
}
465458

466459
// Usages parses the list of key uses in the profile, translating them
@@ -559,7 +552,7 @@ func (p *SigningProfile) hasLocalConfig() bool {
559552
p.OCSP != "" ||
560553
p.ExpiryString != "" ||
561554
p.BackdateString != "" ||
562-
p.CAConstraint.IsCA != false ||
555+
p.CAConstraint.IsCA ||
563556
!p.NotBefore.IsZero() ||
564557
!p.NotAfter.IsZero() ||
565558
p.NameWhitelistString != "" ||

csr/csr.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,11 @@ func getHosts(cert *x509.Certificate) []string {
311311
for _, ip := range cert.IPAddresses {
312312
hosts = append(hosts, ip.String())
313313
}
314-
for _, dns := range cert.DNSNames {
315-
hosts = append(hosts, dns)
316-
}
317-
for _, email := range cert.EmailAddresses {
318-
hosts = append(hosts, email)
319-
}
314+
hosts = append(hosts, cert.DNSNames...)
315+
hosts = append(hosts, cert.EmailAddresses...)
320316
for _, uri := range cert.URIs {
321317
hosts = append(hosts, uri.String())
322318
}
323-
324319
return hosts
325320
}
326321

@@ -504,8 +499,6 @@ func appendCAInfoToCSR(reqConf *CAConfig, csr *x509.CertificateRequest) error {
504499

505500
// appendCAInfoToCSR appends user-defined extension to a CSR
506501
func appendExtensionsToCSR(extensions []pkix.Extension, csr *x509.CertificateRequest) error {
507-
for _, extension := range extensions {
508-
csr.ExtraExtensions = append(csr.ExtraExtensions, extension)
509-
}
502+
csr.ExtraExtensions = append(csr.ExtraExtensions, extensions...)
510503
return nil
511504
}

helpers/derhelpers/derhelpers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ func ParsePrivateKeyDER(keyDER []byte) (key crypto.Signer, err error) {
3434
}
3535
}
3636

37-
switch generalKey.(type) {
37+
switch generalKey := generalKey.(type) {
3838
case *rsa.PrivateKey:
39-
return generalKey.(*rsa.PrivateKey), nil
39+
return generalKey, nil
4040
case *ecdsa.PrivateKey:
41-
return generalKey.(*ecdsa.PrivateKey), nil
41+
return generalKey, nil
4242
case ed25519.PrivateKey:
43-
return generalKey.(ed25519.PrivateKey), nil
43+
return generalKey, nil
4444
}
4545

4646
// should never reach here

helpers/helpers.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,7 @@ func ValidExpiry(c *x509.Certificate) bool {
123123
maxMonths = 120
124124
}
125125

126-
if MonthsValid(c) > maxMonths {
127-
return false
128-
}
129-
return true
126+
return MonthsValid(c) <= maxMonths
130127
}
131128

132129
// SignatureString returns the TLS signature string corresponding to

helpers/testsuite/testing_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func cleanCLIOutput(CLIOutput []byte, item string) (cleanedOutput []byte, err er
352352
eligibleSearchIndex := strings.Index(outputString, "{")
353353
outputString = outputString[eligibleSearchIndex:]
354354
// Make sure the item is present in the output.
355-
if strings.Index(outputString, itemString) == -1 {
355+
if !strings.Contains(outputString, itemString) {
356356
return nil, errors.New("Item " + item + " not found in CLI Output")
357357
}
358358
// We add 2 for the [:"] that follows the item

initca/initca.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func NewFromSigner(req *csr.CertificateRequest, priv crypto.Signer) (cert, csrPE
158158
}
159159

160160
policy.Default.CAConstraint.MaxPathLen = req.CA.PathLength
161-
if req.CA.PathLength != 0 && req.CA.PathLenZero == true {
161+
if req.CA.PathLength != 0 && req.CA.PathLenZero {
162162
log.Infof("ignore invalid 'pathlenzero' value")
163163
} else {
164164
policy.Default.CAConstraint.MaxPathLenZero = req.CA.PathLenZero

0 commit comments

Comments
 (0)