use of com.github.zhenwei.core.asn1.x509.Extension in project pri-fidoiot by secure-device-onboard.
the class OnDieCertSignatureFunction method getIssuingCertificate.
private String getIssuingCertificate(Certificate cert) throws IllegalArgumentException, IOException, CertificateEncodingException {
X509CertificateHolder certholder = new X509CertificateHolder(cert.getEncoded());
AuthorityInformationAccess aia = AuthorityInformationAccess.fromExtensions(certholder.getExtensions());
if (aia == null) {
throw new IllegalArgumentException("AuthorityInformationAccess Extension missing from device certificate.");
}
AccessDescription[] descs = aia.getAccessDescriptions();
if (descs.length != 1) {
throw new IllegalArgumentException("Too many descriptions in AIA certificate extension: " + descs.length);
}
return descs[0].getAccessLocation().getName().toString();
}
use of com.github.zhenwei.core.asn1.x509.Extension in project strimzi by strimzi.
the class SystemTestCertAndKeyBuilder method withSanDnsName.
public SystemTestCertAndKeyBuilder withSanDnsName(String hostName) {
GeneralName dnsName = new GeneralName(dNSName, hostName);
byte[] subjectAltName = encode(GeneralNames.getInstance(new DERSequence(dnsName)));
extensions.add(new Extension(subjectAlternativeName, false, subjectAltName));
return this;
}
use of com.github.zhenwei.core.asn1.x509.Extension in project jruby-openssl by jruby.
the class OCSPSingleResponse method extensions.
@JRubyMethod(name = "extensions")
public IRubyObject extensions() {
Ruby runtime = getRuntime();
Extensions exts = bcSingleResponse.getSingleExtensions();
if (exts == null)
return RubyArray.newEmptyArray(runtime);
ASN1ObjectIdentifier[] extOIDs = exts.getExtensionOIDs();
RubyArray retExts = runtime.newArray(extOIDs.length);
for (ASN1ObjectIdentifier extOID : extOIDs) {
Extension ext = exts.getExtension(extOID);
ASN1Encodable extAsn1 = ext.getParsedValue();
X509Extension retExt = X509Extension.newExtension(runtime, extOID, extAsn1, ext.isCritical());
retExts.append(retExt);
}
return retExts;
}
use of com.github.zhenwei.core.asn1.x509.Extension in project jruby-openssl by jruby.
the class OCSPBasicResponse method convertRubyExtensions.
private Extensions convertRubyExtensions(IRubyObject extensions) {
if (extensions.isNil())
return null;
List<Extension> retExtensions = new ArrayList<Extension>();
Iterator<IRubyObject> rubyExtensions = ((RubyArray) extensions).iterator();
while (rubyExtensions.hasNext()) {
X509Extension rubyExt = (X509Extension) rubyExtensions.next();
Extension ext = Extension.getInstance(((RubyString) rubyExt.to_der()).getBytes());
retExtensions.add(ext);
}
Extension[] exts = new Extension[retExtensions.size()];
retExtensions.toArray(exts);
return new Extensions(exts);
}
use of com.github.zhenwei.core.asn1.x509.Extension in project jruby-openssl by jruby.
the class OCSPBasicResponse method add_nonce.
@JRubyMethod(name = "add_nonce", rest = true)
public OCSPBasicResponse add_nonce(IRubyObject[] args) {
Ruby runtime = getRuntime();
byte[] tmpNonce;
if (Arity.checkArgumentCount(runtime, args, 0, 1) == 0) {
tmpNonce = generateNonce(runtime);
} else {
RubyString input = (RubyString) args[0];
tmpNonce = input.getBytes();
}
extensions.add(new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, tmpNonce));
nonce = tmpNonce;
return this;
}
Aggregations