Skip to content

Commit b183e8b

Browse files
authored
Fix AIA/CRL locations encoded as directoryName instead of URI (#130)
* Fix AIA/CRL locations encoded as directoryName instead of URI AIA accessLocation and CRL distribution point names were always constructed as X.500 directoryName (GeneralName tag [4]), even when the value was an HTTP or LDAP URI. Per IWG Profile v1.1 §3.2.12, the accessLocation value SHOULD point to the OCSP responder as an HTTP URI (uniformResourceIdentifier, GeneralName tag [6]). Extract a parseGeneralName() helper that detects URI schemes (http, https, ldap, ldaps) and encodes them as uniformResourceIdentifier, falling back to X500Name for distinguished name values. * Fix CRL crlIssuer encoding and update test data with URIs - Keep crlIssuer as directoryName (RFC 5280 §4.2.1.13 requires it) - Add TYPE check for DistributionPointName: only apply parseGeneralName for TYPE=0 (fullName), keep X500Name for TYPE=1 (nameRelativeToCRLIssuer) - Update otherExt.json: use HTTP URIs for ACCESSLOCATION and CRL NAME per IWG Profile v1.1 §3.2.12, keep ISSUER as DN
1 parent 6b8c766 commit b183e8b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/main/java/json/OtherExtensionsJsonHelper.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static final AuthorityInfoAccessFactory accessesFromJsonFile(final String
8282
final JsonNode methodNode = elementNode.get(ElementJson.ACCESSMETHOD.name());
8383
final JsonNode locationNode = elementNode.get(ElementJson.ACCESSLOCATION.name());
8484

85-
aiaf.addElement(MethodJson.valueOf(methodNode.asText()), new GeneralName(new X500Name(locationNode.asText())));
85+
aiaf.addElement(MethodJson.valueOf(methodNode.asText()), parseGeneralName(locationNode.asText()));
8686
}
8787
}
8888
}
@@ -114,10 +114,16 @@ public static final CRLDistPoint crlFromJsonFile(final String filename) {
114114
if (distNameNode.has(CrlJson.TYPE.name()) && distNameNode.has(CrlJson.NAME.name())) {
115115
final JsonNode typeNode = distNameNode.get(CrlJson.TYPE.name());
116116
final JsonNode nameNode = distNameNode.get(CrlJson.NAME.name());
117-
118-
dpn = new DistributionPointName(typeNode.asInt(), new GeneralNames(new GeneralName(new X500Name(nameNode.asText()))));
117+
118+
// TYPE=0 (fullName): URI or DN; TYPE=1 (nameRelativeToCRLIssuer): always RDN
119+
if (typeNode.asInt() == 0) {
120+
dpn = new DistributionPointName(0, new GeneralNames(parseGeneralName(nameNode.asText())));
121+
} else {
122+
dpn = new DistributionPointName(typeNode.asInt(), new GeneralNames(new GeneralName(new X500Name(nameNode.asText()))));
123+
}
119124
}
120-
125+
126+
// crlIssuer is always a directoryName per RFC 5280 §4.2.1.13
121127
cdf = new CRLDistPoint(new DistributionPoint[]{new DistributionPoint(dpn, new ReasonFlags(reasonNode.asInt()), new GeneralNames(new GeneralName(new X500Name(issuerNode.asText()))))});
122128
}
123129
}
@@ -127,6 +133,16 @@ public static final CRLDistPoint crlFromJsonFile(final String filename) {
127133

128134
return cdf;
129135
}
136+
137+
private static GeneralName parseGeneralName(final String value) {
138+
final String trimmed = value == null ? "" : value.trim();
139+
final String lower = trimmed.toLowerCase();
140+
if (lower.startsWith("http://") || lower.startsWith("https://")
141+
|| lower.startsWith("ldap://") || lower.startsWith("ldaps://")) {
142+
return new GeneralName(GeneralName.uniformResourceIdentifier, trimmed);
143+
}
144+
return new GeneralName(new X500Name(trimmed));
145+
}
130146

131147
public static final TargetingInformationFactory ekTargetsFromJsonFile(final String filename) {
132148
TargetingInformationFactory tif = TargetingInformationFactory.create();

src/test/resources/otherExt.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
"AUTHORITYINFOACCESS": [
1717
{
1818
"ACCESSMETHOD": "OCSP",
19-
"ACCESSLOCATION": "CN=MyApp ACES CA 2, OU=MyApp Public Sector, O=MyApp, C=US"
19+
"ACCESSLOCATION": "http://ocsp.example.com"
2020
}
2121
],
2222
"CRLDISTRIBUTION": {
2323
"DISTRIBUTIONNAME": {
2424
"TYPE": "0",
25-
"NAME": "CN=MyApp ACES CA 2, OU=MyApp Public Sector, O=MyApp, C=US"
25+
"NAME": "http://crl.example.com/platform.crl"
2626
},
2727
"REASON": "8",
2828
"ISSUER": "CN=MyApp ACES CA 2, OU=MyApp Public Sector, O=MyApp, C=US"

0 commit comments

Comments
 (0)