fix _getAKI() for OpenBSD#7007
Merged
Merged
Conversation
The order of the arguments does matter for OpenBSD's grep (bug or feature). In _getAKI() '... | grep "<search pattern>" -A 1 | ...' fails on OpenBSD. Either moving '-A 1' before the search pattern or use '-e "<search pattern>" -A 1' solves it. Since I always place the search pattern last, I move '-A 1' before the search pattern. Signed-off-by: Thomas Kupper <tom@kupper.org>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts _getAKI() to work on OpenBSD by reordering grep arguments so -A 1 is parsed correctly when extracting the Authority Key Identifier from an X.509 certificate.
Changes:
- Reordered
grepflags/arguments in_getAKI()to avoid OpenBSDgrepparsing issues with-A.
Critical Issues (Must Fix Before Merge)
- None found.
Suggestions (Improvements to Consider)
- Replace
grep -Ausage in_getAKI()with a POSIX-sedextraction to avoid platform-specificgrep -Abehavior (see review comment).
Good Practices (Points to Commend)
- Improves cross-platform compatibility for OpenBSD by addressing a real-world parsing difference.
| _getAKI() { | ||
| _cert="$1" | ||
| ${ACME_OPENSSL_BIN:-openssl} x509 -in "$_cert" -text -noout | grep "X509v3 Authority Key Identifier" -A 1 | _tail_n 1 | tr -d ': ' | sed "s/keyid//" | ||
| ${ACME_OPENSSL_BIN:-openssl} x509 -in "$_cert" -text -noout | grep -A 1 "X509v3 Authority Key Identifier" | _tail_n 1 | tr -d ': ' | sed "s/keyid//" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The order of the arguments does matter for OpenBSD's grep (bug or feature), the pattern must be the last argument.
In _getAKI()
... | grep "<search pattern>" -A 1 | ...fails on OpenBSD.Either moving '-A 1' before the search pattern or use '-e "" -A 1' solves it. Since I always place the search pattern last, I moved '-A 1' before the search pattern.