Skip to content

New API to find certificate given a common name. - #86

Merged
bagarber merged 5 commits into
google:masterfrom
apurv15:certCN
Aug 19, 2025
Merged

bagarber merged 5 commits into
google:masterfrom
apurv15:certCN

Conversation

@apurv15

@apurv15 apurv15 commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

New API to find certificate given a common name.
Save the certChain gotten through resolveChains.

@apurv15

apurv15 commented Aug 10, 2025

Copy link
Copy Markdown
Contributor Author

@alexherrero @bagarber : Can you please review this PR?
This PR allows finding cert given a common name and also to cache certificate chain in WinCertStore.

@apurv15

apurv15 commented Aug 14, 2025

Copy link
Copy Markdown
Contributor Author

@sethvargo : Can you help review this PR?

@sethvargo

Copy link
Copy Markdown

I don't have permissions on this repo, sorry.

@bagarber

bagarber commented Aug 14, 2025 via email

Copy link
Copy Markdown
Contributor

@bagarber bagarber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance there's relevant tests we can add to certtostore_windows_test.go?

@apurv15

apurv15 commented Aug 17, 2025

Copy link
Copy Markdown
Contributor Author

Any chance there's relevant tests we can add to certtostore_windows_test.go?

Yes, i added two new test cases.

Comment thread certtostore_windows.go Outdated
certContext,
)
if err != nil {
return nil, nil, nil, fmt.Errorf("error finding certificate by common name %q: %v",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to omit the word "error" in error strings.

Comment thread certtostore_windows_test.go Outdated
}
t.Fatalf("expected error for unknown common name, got none")
}
if !strings.Contains(err.Error(), "no certificate found") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strongly prefer looking for the value of the error instead of the error string (use errors.Is()).
https://go.dev/wiki/ErrorValueFAQ

Comment thread certtostore_windows_test.go Resolved
@bagarber
bagarber merged commit b2a18cc into google:master Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants