Add pkcs12 import subcommand to the CLI - #3532
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3532 +/- ##
==========================================
+ Coverage 78.38% 78.57% +0.19%
==========================================
Files 700 702 +2
Lines 126759 127237 +478
Branches 17499 17577 +78
==========================================
+ Hits 99354 99973 +619
+ Misses 26516 26366 -150
- Partials 889 898 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
🔒 Security Review — View Report Please review before merging. |
justsmth
marked this pull request as draft
September 17, 2026 13:07
justsmth
force-pushed
the
openssl-pkcs12-import
branch
4 times, most recently
from
September 18, 2026 14:50
45e1521 to
d98e2f9
Compare
justsmth
marked this pull request as ready for review
September 18, 2026 17:22
justsmth
requested review from
WillChilds-Klein
and removed request for
samuel40791765
September 18, 2026 18:07
justsmth
force-pushed
the
openssl-pkcs12-import
branch
from
September 18, 2026 18:22
d98e2f9 to
1e2779c
Compare
nhatnghiho
reviewed
Sep 21, 2026
justsmth
force-pushed
the
openssl-pkcs12-import
branch
from
September 22, 2026 13:31
1e2779c to
cdf4449
Compare
nhatnghiho
approved these changes
Sep 22, 2026
justsmth
enabled auto-merge (squash)
September 22, 2026 18:51
WillChilds-Klein
approved these changes
Sep 22, 2026
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.
Context and motivation
Scripts commonly extract certs and keys with
openssl pkcs12 -in bundle.p12 .... Our CLI had nopkcs12subcommand, so this adds an import-only one aimed at the usual non-interactive invocations.Description of changes
Supports
-in,-out,-nokeys,-nocerts,-nodes,-noout,-passin,-password,-passout,-legacy, and-help. Built onPKCS12_get_key_and_certs, so the MAC is verified before-outis opened. That is stricter than OpenSSL 1.1.x, which truncates-outbefore parsing; a successful run still opens/truncates-outeven when-nooutor-nocerts -nokeyswrites nothing.Output order (certs, then key),
-passwordoverriding-passinregardless of order, empty-password handling, and theMac verify errormessage match OpenSSL 1.1.x. If a key is to be written,-nodes(unencrypted PKCS#8) or-passout(PKCS#8 encrypted with AES-256-CBC) is required; there is no interactive prompt.-nodesoverrides-passout.-legacyis accepted as a no-op so OpenSSL 3 scripts keep working. This library already decrypts the RC2/3DES bags that flag loads the legacy provider for.Not implemented:
-export,-info,-clcerts/-cacerts,-twopass,-nomacver,-chain,-descert, interactive prompts, and theBag Attributescomment lines. Those unsupported options fail rather than being ignored.Testing
38 unit tests plus two comparison tests that export a bundle with the reference OpenSSL and check that both tools produce the same certificates and PEM block sequence. Comparison tests run in CI against OpenSSL 1.1.1 and 3.0.
The unit-test builder uses
PKCS12_createdefaults, so cert bags are RC2-40 and the key bag is 3DES. Tests do not construct RC4 or OpenSSL 3 PBES2/AES-encrypted bundles (the latter is covered only when the comparison job uses a 3.xopenssl pkcs12 -export), and they do not exercise BER indefinite-length inputs (the library handles those).Review considerations
CLI-only, no public API or FIPS changes. The AWS-LC parser is stricter than OpenSSL in ways that surface here: bundles without a MAC (
-export -nomac) are rejected rather than imported with a warning, and bundles with more than one private key are rejected. Like the other subcommands, the CLIReadAllhelper caps input at 1 MiB.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.