/** * stores the given certificate into the keystore with the given alias name * * @param certAlias the alias name to be used for this certificate * @param certificate the X509 certificate data * @throws Exception in case of any issues related to certificate data parsing */ public static void addCertificate( String certAlias, byte[] certificate ) throws Exception { try { parser.engineInit( new ByteArrayInputStream( certificate ) ); X509Certificate cert = ( X509Certificate ) parser.engineRead(); ks.setCertificateEntry( certAlias, cert ); } catch ( Exception ex ) { LOG.warn( "failed to load the certificate associated with the alias {}", certAlias, ex ); throw ex; } }
static Collection<Certificate> readAllCerts(byte[] contentsKey) throws StreamParsingException { X509CertParser cr = new X509CertParser(); cr.engineInit(new ByteArrayInputStream(contentsKey)); return cr.engineReadAll(); }
static Collection<Certificate> readAllCerts(byte[] contentsKey) throws StreamParsingException { X509CertParser cr = new X509CertParser(); cr.engineInit(new ByteArrayInputStream(contentsKey)); return cr.engineReadAll(); }
private Set createCerts(List list, X509CertStoreSelector xselector) throws StoreException { Set certSet = new HashSet(); Iterator it = list.iterator(); X509CertParser parser = new X509CertParser(); while (it.hasNext()) { try { parser.engineInit(new ByteArrayInputStream((byte[])it .next())); X509Certificate cert = (X509Certificate)parser .engineRead(); if (xselector.match((Object)cert)) { certSet.add(cert); } } catch (Exception e) { } } return certSet; }
/** * Verifies a signature using the sub-filter adbe.x509.rsa_sha1. * @param contentsKey the /Contents key * @param certsKey the /Cert key * @param provider the provider or <code>null</code> for the default provider */ public PdfPKCS7(byte[] contentsKey, byte[] certsKey, String provider) { try { this.provider = provider; X509CertParser cr = new X509CertParser(); cr.engineInit(new ByteArrayInputStream(certsKey)); certs = cr.engineReadAll(); signCerts = certs; signCert = (X509Certificate)certs.iterator().next(); crls = new ArrayList(); ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(contentsKey)); digest = ((DEROctetString)in.readObject()).getOctets(); if (provider == null) sig = Signature.getInstance("SHA1withRSA"); else sig = Signature.getInstance("SHA1withRSA", provider); sig.initVerify(signCert.getPublicKey()); } catch (Exception e) { throw new ExceptionConverter(e); } }
/** * Verifies a signature using the sub-filter adbe.x509.rsa_sha1. * @param contentsKey the /Contents key * @param certsKey the /Cert key * @param provider the provider or <code>null</code> for the default provider */ public PdfPKCS7(final byte[] contentsKey, final byte[] certsKey, final String provider) { try { this.provider = provider; final X509CertParser cr = new X509CertParser(); cr.engineInit(new ByteArrayInputStream(certsKey)); this.certs = cr.engineReadAll(); this.signCerts = this.certs; this.signCert = (X509Certificate)this.certs.iterator().next(); this.crls = new ArrayList(); final ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(contentsKey)); this.digest = ((DEROctetString)in.readObject()).getOctets(); if (provider == null) { this.sig = Signature.getInstance("SHA1withRSA"); } else { this.sig = Signature.getInstance("SHA1withRSA", provider); } this.sig.initVerify(this.signCert.getPublicKey()); } catch (final Exception e) { throw new ExceptionConverter(e); } }
this.provider = provider; X509CertParser cr = new X509CertParser(); cr.engineInit(new ByteArrayInputStream(certsKey)); certs = cr.engineReadAll(); signCerts = certs;
private X509Certificate extractCertificate(final String[] domains, InputStream inputStream) throws StreamParsingException { X509CertParser certParser = new X509CertParser(); certParser.engineInit(inputStream); X509Certificate certificate = (X509Certificate) certParser.engineRead(); certificateStorage.saveCertificate(domains, certificate); return certificate; }
this.provider = provider; X509CertParser cr = new X509CertParser(); cr.engineInit(new ByteArrayInputStream(certsKey)); certs = cr.engineReadAll(); signCerts = certs;
certParser.engineInit(config.getEncryptionCertificate().getInputStream()); LOGGER.debug("Invoking certificate engine to parse the certificate {}", config.getEncryptionCertificate()); final X509CertificateObject cert = (X509CertificateObject) certParser.engineRead();
@Override public void saveCertificate(String[] domains, X509Certificate certificate) { for (String domain:domains){ try(OutputStream outputStream = new FileOutputStream(domain + ".crt")) { X509Utils.savePEM(outputStream, certificate); } catch (IOException e) { throw new CertificateStorageException(e); } } if (saveCAIntermediateCertificate){ try{ String caIntermediateCertificateURL = X509Utils.getCACertificateURL(certificate); if (caIntermediateCertificateURL != null){ X509CertificateObject caIntermediateCertificate; try(InputStream is = new URL(caIntermediateCertificateURL).openStream()){ X509CertParser certParser = new X509CertParser(); certParser.engineInit(is); caIntermediateCertificate = (X509CertificateObject) certParser.engineRead(); } for (String domain:domains){ try(OutputStream outputStream = new FileOutputStream(domain + ".chain.crt")) { X509Utils.savePEM(outputStream, caIntermediateCertificate); } } } }catch (IOException|StreamParsingException e) { throw new CertificateStorageException(e); } } }
certParser.engineInit(config.getEncryptionCertificate().getInputStream()); LOGGER.debug("Invoking certificate engine to parse the certificate [{}]", config.getEncryptionCertificate()); val cert = (X509CertificateObject) certParser.engineRead();
parser.engineInit( new ByteArrayInputStream( adminEntry.get( TlsKeyGenerator.USER_CERTIFICATE_AT ) .getBytes() ) );
x509CertParser.engineInit(new ByteArrayInputStream(certsKey)); certificateChain = x509CertParser.engineReadAll(); signerCertificate = (X509Certificate) certificateChain.iterator().next();
x509CertParser.engineInit(new ByteArrayInputStream(cmsData)); try { certificateChain = x509CertParser.engineReadAll();
cr.engineInit(new ByteArrayInputStream(contentsKey)); this.certs = cr.engineReadAll(); final X509CRLParser cl = new X509CRLParser();
cr.engineInit(new ByteArrayInputStream(contentsKey)); certs = cr.engineReadAll(); X509CRLParser cl = new X509CRLParser();
cr.engineInit(new ByteArrayInputStream(contentsKey)); certs = cr.engineReadAll(); X509CRLParser cl = new X509CRLParser();
cr.engineInit(new ByteArrayInputStream(contentsKey)); certs = cr.engineReadAll();