Encode Netscape IA5String extensions correctly#350
Open
bsommerer wants to merge 1 commit intojruby:masterfrom
Open
Encode Netscape IA5String extensions correctly#350bsommerer wants to merge 1 commit intojruby:masterfrom
bsommerer wants to merge 1 commit intojruby:masterfrom
Conversation
create_ext has no special case for nsComment (OID 2.16.840.1.113730.1.13)
and other Netscape IA5String extensions, so they fall through to the
generic else branch which double-wraps the value in OCTET STRINGs:
OCTET STRING { OCTET STRING { raw ASCII } }
CRuby's native OpenSSL bindings produce the correct encoding:
OCTET STRING { IA5String "..." }
The malformed encoding causes BouncyCastle to crash when parsing
certificates containing these extensions, as it tries to interpret the
raw ASCII bytes as ASN.1 structures.
Add isNetscapeIA5StringExtension() covering all Netscape extensions
defined as IA5String (nsBaseUrl, nsRevocationUrl, nsCaRevocationUrl,
nsRenewalUrl, nsCaPolicyUrl, nsSslServerName, nsComment). nsCertType
is excluded as it is a BIT STRING already handled separately.
943a55d to
c15ce05
Compare
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.
Summary
X509ExtensionFactory#create_exthas no special case fornsComment(OID2.16.840.1.113730.1.13) and other Netscape IA5String extensions. They fall through to the genericelsebranch which double-wraps the value in OCTET STRINGs:This causes BouncyCastle to crash when parsing certificates containing these extensions:
Changes
isNetscapeIA5StringExtension()covering all Netscape extensions defined as IA5String:nsBaseUrl,nsRevocationUrl,nsCaRevocationUrl,nsRenewalUrl,nsCaPolicyUrl,nsSslServerName,nsCommentnsCertType(BIT STRING) is excluded as it is already handled separatelynsCommentandnsBaseUrlHow to reproduce
16 22(IA5String tag + length)04 28(OCTET STRING tag + length)Fixes #349