Skip to content

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

Merged
tsaarni merged 1 commit intomasterfrom
convenience-getters
Oct 26, 2024
Merged

Added convenience getters for certificate and private key for single-value use#71
tsaarni merged 1 commit intomasterfrom
convenience-getters

Conversation

@tsaarni
Copy link
Copy Markdown
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
@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