Skip to content

fix _getAKI() for OpenBSD#7007

Merged
neilpang merged 2 commits into
acmesh-official:devfrom
boretom:fix/OpenBSD-getAKI
Jun 4, 2026
Merged

fix _getAKI() for OpenBSD#7007
neilpang merged 2 commits into
acmesh-official:devfrom
boretom:fix/OpenBSD-getAKI

Conversation

@boretom

@boretom boretom commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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.

neilpang and others added 2 commits May 16, 2026 11:17
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>

Copilot AI 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.

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 grep flags/arguments in _getAKI() to avoid OpenBSD grep parsing issues with -A.

Critical Issues (Must Fix Before Merge)

  • None found.

Suggestions (Improvements to Consider)

  • Replace grep -A usage in _getAKI() with a POSIX-sed extraction to avoid platform-specific grep -A behavior (see review comment).

Good Practices (Points to Commend)

  • Improves cross-platform compatibility for OpenBSD by addressing a real-world parsing difference.

Comment thread acme.sh
_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//"
@neilpang neilpang merged commit dfbe2c5 into acmesh-official:dev Jun 4, 2026
36 checks passed
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