Skip to content

Commit

Permalink
Merge pull request #1304 from testwill/master
Browse files Browse the repository at this point in the history
  • Loading branch information
nickysemenza authored Jun 12, 2023
2 parents 68e04e2 + 5e37590 commit 50f8789
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 36 deletions.
5 changes: 1 addition & 4 deletions bundler/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,7 @@ func isSelfSigned(cert *x509.Certificate) bool {
}

func isChainRootNode(cert *x509.Certificate) bool {
if isSelfSigned(cert) {
return true
}
return false
return isSelfSigned(cert)
}

func (b *Bundler) verifyChain(chain []*fetchedIntermediate) bool {
Expand Down
17 changes: 5 additions & 12 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cloudflare/cfssl/helpers"
"github.com/cloudflare/cfssl/log"
ocspConfig "github.com/cloudflare/cfssl/ocsp/config"

// empty import of zlint/v3 required to have lints registered.
_ "github.com/zmap/zlint/v3"
"github.com/zmap/zlint/v3/lint"
Expand Down Expand Up @@ -296,7 +297,7 @@ func (p *SigningProfile) populate(cfg *Config) error {

if p.AuthRemote.AuthKeyName != "" {
log.Debug("match auth remote key in profile to auth_keys section")
if key, ok := cfg.AuthKeys[p.AuthRemote.AuthKeyName]; ok == true {
if key, ok := cfg.AuthKeys[p.AuthRemote.AuthKeyName]; ok {
if key.Type == "standard" {
p.RemoteProvider, err = auth.New(key.Key, nil)
if err != nil {
Expand Down Expand Up @@ -441,11 +442,7 @@ func (p *Signing) NeedsRemoteSigner() bool {
}
}

if p.Default.RemoteServer != "" {
return true
}

return false
return p.Default.RemoteServer != ""
}

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

if p.Default.RemoteServer == "" {
return true
}

return false
return p.Default.RemoteServer == ""
}

// Usages parses the list of key uses in the profile, translating them
Expand Down Expand Up @@ -559,7 +552,7 @@ func (p *SigningProfile) hasLocalConfig() bool {
p.OCSP != "" ||
p.ExpiryString != "" ||
p.BackdateString != "" ||
p.CAConstraint.IsCA != false ||
p.CAConstraint.IsCA ||
!p.NotBefore.IsZero() ||
!p.NotAfter.IsZero() ||
p.NameWhitelistString != "" ||
Expand Down
13 changes: 3 additions & 10 deletions csr/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,11 @@ func getHosts(cert *x509.Certificate) []string {
for _, ip := range cert.IPAddresses {
hosts = append(hosts, ip.String())
}
for _, dns := range cert.DNSNames {
hosts = append(hosts, dns)
}
for _, email := range cert.EmailAddresses {
hosts = append(hosts, email)
}
hosts = append(hosts, cert.DNSNames...)
hosts = append(hosts, cert.EmailAddresses...)
for _, uri := range cert.URIs {
hosts = append(hosts, uri.String())
}

return hosts
}

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

// appendCAInfoToCSR appends user-defined extension to a CSR
func appendExtensionsToCSR(extensions []pkix.Extension, csr *x509.CertificateRequest) error {
for _, extension := range extensions {
csr.ExtraExtensions = append(csr.ExtraExtensions, extension)
}
csr.ExtraExtensions = append(csr.ExtraExtensions, extensions...)
return nil
}
8 changes: 4 additions & 4 deletions helpers/derhelpers/derhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ func ParsePrivateKeyDER(keyDER []byte) (key crypto.Signer, err error) {
}
}

switch generalKey.(type) {
switch generalKey := generalKey.(type) {
case *rsa.PrivateKey:
return generalKey.(*rsa.PrivateKey), nil
return generalKey, nil
case *ecdsa.PrivateKey:
return generalKey.(*ecdsa.PrivateKey), nil
return generalKey, nil
case ed25519.PrivateKey:
return generalKey.(ed25519.PrivateKey), nil
return generalKey, nil
}

// should never reach here
Expand Down
5 changes: 1 addition & 4 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ func ValidExpiry(c *x509.Certificate) bool {
maxMonths = 120
}

if MonthsValid(c) > maxMonths {
return false
}
return true
return MonthsValid(c) <= maxMonths
}

// SignatureString returns the TLS signature string corresponding to
Expand Down
2 changes: 1 addition & 1 deletion helpers/testsuite/testing_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func cleanCLIOutput(CLIOutput []byte, item string) (cleanedOutput []byte, err er
eligibleSearchIndex := strings.Index(outputString, "{")
outputString = outputString[eligibleSearchIndex:]
// Make sure the item is present in the output.
if strings.Index(outputString, itemString) == -1 {
if !strings.Contains(outputString, itemString) {
return nil, errors.New("Item " + item + " not found in CLI Output")
}
// We add 2 for the [:"] that follows the item
Expand Down
2 changes: 1 addition & 1 deletion initca/initca.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func NewFromSigner(req *csr.CertificateRequest, priv crypto.Signer) (cert, csrPE
}

policy.Default.CAConstraint.MaxPathLen = req.CA.PathLength
if req.CA.PathLength != 0 && req.CA.PathLenZero == true {
if req.CA.PathLength != 0 && req.CA.PathLenZero {
log.Infof("ignore invalid 'pathlenzero' value")
} else {
policy.Default.CAConstraint.MaxPathLenZero = req.CA.PathLenZero
Expand Down

0 comments on commit 50f8789

Please sign in to comment.