Repository navigation
fix: label the leaf certificate with the key chain alias - #15
Closed
windsoralv wants to merge 1 commit into
Closed
windsoralv wants to merge 1 commit into
windsoralv wants to merge 1 commit into
Conversation
The leaf certificate bag of a private key chain was written with its subject as friendlyName, so Windows showed e.g. "CN=*.example.com" as the imported certificate's Friendly Name. Write the entry alias instead, as for the private key bag. Java keytool and `openssl pkcs12 -export -name` label the leaf the same way.
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.
When
Pkcs12Writerwrites aPrivateKeyChain, the private key bag's friendlyName is the entry alias, but the leafcertificate bag's friendlyName is the certificate's subject. Windows shows the leaf certificate's friendlyName as its
Friendly Name on import (certlm.msc, the IIS binding dialog), so a PFX written with alias
webshows up asCN=*.example.cominstead ofweb.This PR writes the entry alias as the leaf certificate's friendlyName, the same value the key bag already carries.
The other certificates in the chain keep their current labels.
Reference behaviour
pkcs12 -export -name <name>: "the friendly name for the certificates and private key"(
doc/man1/openssl-pkcs12.pod.in).PKCS12_create_ex2(crypto/pkcs12/p12_crt.c) puts the name and thelocalKeyID on the leaf certificate bag and on the key bag. This repository's own
tests/assets/unicode-subject-chain.p12, written with-name identity, shows the leaf bag carryingfriendlyName: identity.sun.security.pkcs12.PKCS12KeyStore.engineStore): the leaf bag of a key entry (i == 0)gets
getBagAttributes(keyEntry.alias, keyEntry.keyId, ...), so its friendlyName is the alias.Compatibility
KeyStore::from_pkcs12withStrictandRelaxedtakes a key chain's alias from the key bag, so importedaliases are unchanged.
Raw, a certificate entry's alias is its friendlyName. A leaf now carries the key's alias, so it is importedas
<alias>#2, beside the key entry. The existingraw_import_preserves_keys_and_certificates_with_colliding_aliasestest passes unchanged.on the leaf bag adds no new failure. Chain certificates keep the subject label, including the fix: write certificate chains with Unicode subjects #14 rule that omits
it for subjects a BMPString cannot hold.
Pkcs12Archivereports the new leaf label.Tests
leaf_certificate_bag_takes_the_entry_alias: writes a two-certificate chain under aliasidentityandreads the bags back through
Pkcs12Archive. The key bag and the leaf bag areidentity, the chain certificatekeeps its subject, and a
Strictre-import keeps the alias.unicode_certificate_subjects_round_trip_without_generated_friendly_namesnow asserts that each rewrittencertificate bag carries the same friendlyName as OpenSSL's original fixture (leaf
identity, CA none), not thatnone of them has one.
Validation (Rust 1.95.0, macOS aarch64), the same commands as CI:
cargo fmt --check: passed.cargo clippy --workspace --examples --tests -- -D warnings: passed.cargo test --workspace --examples --tests: passed (23 unit, 6 archive, 3 import-policy, 5 API,12 serialization).
A bugfix release containing this would let downstream users get the leaf label from the registry release.