5757import org .bouncycastle .asn1 .x509 .DistributionPoint ;
5858import org .bouncycastle .asn1 .x509 .DistributionPointName ;
5959import org .bouncycastle .asn1 .x509 .Extension ;
60+ import org .bouncycastle .asn1 .x509 .AccessDescription ;
61+ import org .bouncycastle .asn1 .x509 .AuthorityInformationAccess ;
6062import org .bouncycastle .asn1 .x509 .GeneralName ;
6163import org .bouncycastle .asn1 .x509 .GeneralNames ;
6264import org .bouncycastle .util .encoders .Hex ;
@@ -599,8 +601,7 @@ else if ( entry.respondsTo("value") ) {
599601 }
600602 else if ( dpName != null && dpName .getType () == DistributionPointName .NAME_RELATIVE_TO_CRL_ISSUER ) {
601603 val .append (ByteList .plain ("Relative Name:" ));
602- val .append ('\n' );
603- val .append (ByteList .plain (" " ));
604+ val .append ('\n' ).append (' ' ).append (' ' );
604605 val .append (ByteList .plain (dpName .getName ().toString ()));
605606 }
606607 }
@@ -613,6 +614,35 @@ else if ( dpName != null && dpName.getType() == DistributionPointName.NAME_RELAT
613614 }
614615 }
615616
617+ if ( oid .equals ("1.3.6.1.5.5.7.1.1" ) ) { // authorityInfoAccess
618+ try {
619+ ASN1Encodable value = getRealValue ();
620+ final ByteList val = new ByteList (64 );
621+
622+ if ( value instanceof ASN1OctetString ) {
623+ value = ASN1 .readObject ( ((ASN1OctetString ) value ).getOctets () );
624+ }
625+
626+ final AuthorityInformationAccess infoAccess = AuthorityInformationAccess .getInstance (value );
627+ final AccessDescription [] descriptions = infoAccess .getAccessDescriptions ();
628+
629+ for ( int i = 0 ; i < descriptions .length ; i ++ ) {
630+ if ( i > 0 ) val .append ('\n' );
631+
632+ final AccessDescription description = descriptions [i ];
633+ val .append ( ByteList .plain ( accessDescriptionMethodName (runtime , description ) ) );
634+ val .append (' ' ).append ('-' ).append (' ' );
635+ formatGeneralName (description .getAccessLocation (), val , false );
636+ }
637+
638+ return runtime .newString ( val );
639+ }
640+ catch (IllegalArgumentException e ) {
641+ debugStackTrace (runtime , e );
642+ return rawValueAsString (context );
643+ }
644+ }
645+
616646 return rawValueAsString (context );
617647 }
618648 catch (IOException e ) {
@@ -661,6 +691,19 @@ private static byte[] keyidBytes(ASN1Primitive keyid) throws IOException {
661691 return keyid .getEncoded (ASN1Encoding .DER );
662692 }
663693
694+ private static String accessDescriptionMethodName (final Ruby runtime , final AccessDescription description ) {
695+ final ASN1ObjectIdentifier method = description .getAccessMethod ();
696+ if ( AccessDescription .id_ad_ocsp .equals (method ) ) return "OCSP" ;
697+ if ( AccessDescription .id_ad_caIssuers .equals (method ) ) return "CA Issuers" ;
698+
699+ final Integer nid = ASN1 .oid2nid (runtime , method );
700+ if ( nid != null ) {
701+ final String name = ASN1 .nid2ln (runtime , nid );
702+ if ( name != null ) return name ;
703+ }
704+ return method .getId ();
705+ }
706+
664707 @ SuppressWarnings ("unchecked" )
665708 private static boolean formatGeneralName (final GeneralName name , final ByteList out , final boolean slashed ) {
666709 final ASN1Encodable obj = name .getName ();
0 commit comments