@Test public void testConvertByteArrayToX509Certificate_Ok() throws Exception { InputStream cert = Thread.currentThread().getContextClassLoader().getResourceAsStream("server.crt"); Assert.assertNotNull(X509CertUtil.toCert(Util.toByteArray(cert))); }
public static Certificate toCert(byte[] bytes) { if (bytes == null) { throw new IllegalArgumentException("Input bytes can not be null"); } try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); return certFactory.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new IllegalArgumentException("Certificate generation failed", e); } }
X509CertUtil { public static Certificate toCert(byte[] bytes) { if (bytes == null) { throw new IllegalArgumentException("Input bytes can not be null"); } try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); return certFactory.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new IllegalArgumentException("Certificate generation failed", e); } } }
X509CertUtil { public static Certificate toCert(byte[] bytes) { if (bytes == null) { throw new IllegalArgumentException("Input bytes can not be null"); } try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); return certFactory.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new IllegalArgumentException("Certificate generation failed", e); } } private  X509CertUtil(); }
X509CertUtil { public static Certificate toCert(byte[] bytes) { if (bytes == null) { throw new IllegalArgumentException("Input bytes can not be null"); } try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); return certFactory.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new IllegalArgumentException("Certificate generation failed", e); } } private  X509CertUtil(); static Certificate toCert(byte[] bytes); }
X509CertUtil { public static Certificate toCert(byte[] bytes) { if (bytes == null) { throw new IllegalArgumentException("Input bytes can not be null"); } try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); return certFactory.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new IllegalArgumentException("Certificate generation failed", e); } } private  X509CertUtil(); static Certificate toCert(byte[] bytes);  }