Generate X509Certificate from byte[]?

前端 未结 3 1867
庸人自扰
庸人自扰 2021-01-31 07:30

Is there a possibility to generate an java.security.cert.X509Certificate from an byte[]?

3条回答
  •  无人共我
    2021-01-31 08:07

    InputStream stream = null;
    byte[] bencoded = javax.xml.bind.DatatypeConverter.parseBase64Binary(x509CertificateStr);
    
    try {
        CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
        cert = (X509Certificate) certFactory.generateCertificate(stream);
    
    } catch (java.security.cert.CertificateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    

提交回复
热议问题