/** * Return the ASN.1 encoding of this holder's certificate. * * @return a DER encoded byte array. * @throws IOException if an encoding cannot be generated. */ public byte[] getEncoded() throws IOException { return x509Certificate.getEncoded(); } }
/** * Return the ASN.1 encoding of this holder's certificate. * * @return a DER encoded byte array. * @throws IOException if an encoding cannot be generated. */ public byte[] getEncoded() throws IOException { return x509Certificate.getEncoded(); }
public byte[] getEncoded() throws IOException { return certificate.getEncoded(ASN1Encoding.DER); }
public byte[] getCertificateBytes() { if (cert != null) { try { return cert.getEncoded(); } catch (IOException e) { throw new IllegalStateException("can't decode certificate: " + e); } } if (publicKeyCert != null) { return publicKeyCert; } return attributeCert; }
public byte[] getEncoded() throws CertificateEncodingException { try { return c.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
public byte[] getEncoded() throws CertificateEncodingException { try { return c.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
private Certificate decodeCertificate(Object cert) { if (provider != null) { try { CertificateFactory certFact = CertificateFactory.getInstance("X.509", provider); return certFact.generateCertificate(new ByteArrayInputStream(org.spongycastle.asn1.x509.Certificate.getInstance(cert).getEncoded())); } catch (Exception e) { return null; } } else { try { CertificateFactory certFact = CertificateFactory.getInstance("X.509"); return certFact.generateCertificate(new ByteArrayInputStream(org.spongycastle.asn1.x509.Certificate.getInstance(cert).getEncoded())); } catch (Exception e) { return null; } } }
/** * Encode this {@link Certificate} to an {@link OutputStream}. * * @param output the {@link OutputStream} to encode to. * @throws IOException */ public void encode(OutputStream output) throws IOException { Vector derEncodings = new Vector(this.certificateList.length); int totalLength = 0; for (int i = 0; i < this.certificateList.length; ++i) { byte[] derEncoding = certificateList[i].getEncoded(ASN1Encoding.DER); derEncodings.addElement(derEncoding); totalLength += derEncoding.length + 3; } TlsUtils.checkUint24(totalLength); TlsUtils.writeUint24(totalLength, output); for (int i = 0; i < derEncodings.size(); ++i) { byte[] derEncoding = (byte[])derEncodings.elementAt(i); TlsUtils.writeOpaque24(derEncoding, output); } }
public static X509Certificate parseCertificate(JcaJceHelper helper, byte[] encoding) throws IOException { try { /* * NOTE: We want to restrict 'encoding' to a binary BER encoding, but * CertificateFactory.generateCertificate claims to require DER encoding, and also * supports Base64 encodings (in PEM format), which we don't support. * * Re-encoding validates as BER and produces DER. */ byte[] derEncoding = Certificate.getInstance(encoding).getEncoded(ASN1Encoding.DER); ByteArrayInputStream input = new ByteArrayInputStream(derEncoding); X509Certificate certificate = (X509Certificate)helper.createCertificateFactory("X.509").generateCertificate(input); if (input.available() != 0) { throw new IOException("Extra data detected in stream"); } return certificate; } catch (GeneralSecurityException e) { throw new TlsCryptoException("unable to decode certificate", e); } }
public PKCS12SafeBagBuilder(Certificate certificate) throws IOException { this.bagType = PKCSObjectIdentifiers.certBag; this.bagValue = new CertBag(PKCSObjectIdentifiers.x509Certificate, new DEROctetString(certificate.getEncoded())); }
public PKCS12SafeBagBuilder(Certificate certificate) throws IOException { this.bagType = PKCSObjectIdentifiers.certBag; this.bagValue = new CertBag(PKCSObjectIdentifiers.x509Certificate, new DEROctetString(certificate.getEncoded())); }
if (pair.getForward() != null) bytesList.add(pair.getForward().getEncoded()); bytesList.add(pair.getReverse().getEncoded());