Skip to content

Commit

Permalink
Simplify certificate nil check in smime.go
Browse files Browse the repository at this point in the history
Replaced redundant `nil` check with a concise length check for `keyPairTLS.Certificate`. This ensures cleaner and more readable code while maintaining the same functionality.
  • Loading branch information
wneessen committed Jan 8, 2025
1 parent a1c1ecb commit f2bb3c7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion smime.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func getLeafCertificate(keyPairTLS *tls.Certificate) (*x509.Certificate, error)
return keyPairTLS.Leaf, nil
}

if keyPairTLS.Certificate == nil || len(keyPairTLS.Certificate) == 0 {
if len(keyPairTLS.Certificate) == 0 {
return nil, errors.New("certificate chain is empty")
}
cert, err := x509.ParseCertificate(keyPairTLS.Certificate[0])
Expand Down

0 comments on commit f2bb3c7

Please sign in to comment.