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

Added convenience getters for certificate and private key for single-value use #71

Merged
merged 1 commit into from
Oct 26, 2024

Conversation

tsaarni
Copy link
Owner

@tsaarni tsaarni commented Oct 26, 2024

Added Certificate.CertPEM() and Certificate.KeyPEM() methods as convenience methods to return the certificate and key in PEM format for using in single-value context, for example when populating struct field. They are alternative to the Certificate.PEM() method, which returns the certificate, key, and error.

c := Certificate{Subject: "CN=Joe"}

var foo = struct {
	cert []byte
	key  []byte
}{
	cert: c.CertPEM(),
	key:  c.KeyPEM(),
}

If there are errors, the convenience methods cannot return error code. They will call panic() instead.

@tsaarni tsaarni changed the title Added convenience getters for single-value use Added convenience getters for certificate and private key for single-value use Oct 26, 2024
@tsaarni tsaarni merged commit 74fa8cd into master Oct 26, 2024
3 checks passed
@tsaarni tsaarni deleted the convenience-getters branch October 26, 2024 20:49
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.

1 participant