-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add pemutil.UnbundleCertificate #352
Conversation
Removes a certificate from a bundle.
pemutil/pem.go
Outdated
block, err := Serialize(cert) | ||
if err != nil { | ||
return nil, false, err | ||
} | ||
keep = append(keep, pem.EncodeToMemory(block)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify these lines with:
block, err := Serialize(cert) | |
if err != nil { | |
return nil, false, err | |
} | |
keep = append(keep, pem.EncodeToMemory(block)...) | |
keep = append(keep, pem.EncodeToMemory(&pem.Block{ | |
Type: "CERTIFICATE", | |
Bytes: cert.Raw, | |
})...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pemutil/pem.go
Outdated
func UnbundleCertificate(bundlePEM []byte, certsPEM ...[]byte) ([]byte, bool, error) { | ||
drop := make(map[[sha256.Size224]byte]bool, len(certsPEM)) | ||
for i := range certsPEM { | ||
cert, err := ParseCertificate(certsPEM[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see using this function but having certsPEM[i]
as a certificate bundle. If a read a bundle and want to remove one cert, I don't want to split the bundle in multiple certs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// UnbundleCertificate removes PEM-encoded certificates from a PEM-encoded | ||
// certificate bundle. | ||
func UnbundleCertificate(bundlePEM []byte, certsPEM ...[]byte) ([]byte, bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optionally, return the original bundle if len(certsPEM) == 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Removes a certificate from a bundle.
Name of feature:
pemutil.UnbundleCertificate.
Pain or issue this feature alleviates:
BundleCertificate lets you create a new bundle with additional certificates but there was no way to remove certificates from a bundle.
Why is this important to the project (if not answered above):
Is there documentation on how to use this feature? If so, where?
In what environments or workflows is this feature supported?
In what environments or workflows is this feature explicitly NOT supported (if any)?
Supporting links/other PRs/issues:
💔Thank you!