Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug log CA certs and hashes in scepclient #157

Merged
merged 5 commits into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cmd/scepclient/scepclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func run(cfg runCfg) error {
}
}

if cfg.debug {
logCerts(level.Debug(logger), certs)
}

var signerCert *x509.Certificate
{
if cert != nil {
Expand Down Expand Up @@ -221,9 +225,21 @@ func run(cfg runCfg) error {
return nil
}

// logCerts logs the count, number, RDN, and SHA-256 of certs to logger
func logCerts(logger log.Logger, certs []*x509.Certificate) {
logger.Log("msg", "cacertlist", "count", len(certs))
for i, cert := range certs {
jessepeterson marked this conversation as resolved.
Show resolved Hide resolved
logger.Log(
"msg", "cacertlist",
"number", i,
"rdn", cert.Subject.ToRDNSequence().String(),
"sha256", fmt.Sprintf("%x", sha256.Sum256(cert.Raw)),
)
}
}

// Determine the correct recipient based on the fingerprint.
// In case of NDES that is the last certificate in the chain, not the RA cert.
// Note: this function assumes that the input certs are sorted as a valid chain.
// Return a full chain starting with the cert that matches the fingerprint.
func findRecipients(fingerprint string, certs []*x509.Certificate) ([]*x509.Certificate, error) {
fingerprint = strings.Join(strings.Split(fingerprint, " "), "")
Expand Down