@@ -1984,36 +1984,21 @@ private SafeBag createSafeBag(String certId, Certificate cert, boolean overwrite
19841984 if (cert instanceof X509Certificate )
19851985 {
19861986 TBSCertificate tbsCert = TBSCertificate .getInstance (((X509Certificate )cert ).getTBSCertificate ());
1987- Extensions exts = tbsCert .getExtensions ();
1988- if (exts != null )
1989- {
1990- Extension extUsage = exts .getExtension (Extension .extendedKeyUsage );
1991- if (extUsage != null )
1992- {
1993- ASN1EncodableVector fSeq = new ASN1EncodableVector ();
19941987
1995- // oracle trusted key usage OID.
1996- fSeq .add (MiscObjectIdentifiers .id_oracle_pkcs12_trusted_key_usage );
1997- fSeq .add (new DERSet (ExtendedKeyUsage .getInstance (extUsage .getParsedValue ()).getUsages ()));
1998- fName .add (new DERSequence (fSeq ));
1999- }
2000- else
2001- {
2002- ASN1EncodableVector fSeq = new ASN1EncodableVector ();
1988+ ASN1OctetString eku = Extensions .getExtensionValue (tbsCert .getExtensions (),
1989+ Extension .extendedKeyUsage );
20031990
2004- fSeq . add ( MiscObjectIdentifiers . id_oracle_pkcs12_trusted_key_usage ) ;
2005- fSeq . add ( new DERSet ( KeyPurposeId . anyExtendedKeyUsage ));
2006- fName . add ( new DERSequence ( fSeq ));
2007- }
1991+ DERSet attrValue ;
1992+ if ( eku != null )
1993+ {
1994+ attrValue = new DERSet ( ExtendedKeyUsage . getInstance ( eku . getOctets ()). getUsages ());
20081995 }
20091996 else
20101997 {
2011- ASN1EncodableVector fSeq = new ASN1EncodableVector ();
2012-
2013- fSeq .add (MiscObjectIdentifiers .id_oracle_pkcs12_trusted_key_usage );
2014- fSeq .add (new DERSet (KeyPurposeId .anyExtendedKeyUsage ));
2015- fName .add (new DERSequence (fSeq ));
1998+ attrValue = new DERSet (KeyPurposeId .anyExtendedKeyUsage );
20161999 }
2000+
2001+ fName .add (new DERSequence (MiscObjectIdentifiers .id_oracle_pkcs12_trusted_key_usage , attrValue ));
20172002 }
20182003
20192004 return new SafeBag (certBag , cBag .toASN1Primitive (), new DERSet (fName ));
0 commit comments