将证书(.crt)编码到X509中

时间:2017-09-22 07:20:58

标签: swift x509 asn.1

因此我们在android中有证书文件(.crt),我们使用以下代码对其进行编码:

    CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
    InputStream is = null;
    try {
        is = getAppContext().getResources().openRawResource(R.raw.newCertificate);
        X509Certificate publicCert = (X509Certificate) certFactory.generateCertificate(is);
        return publicCert.getEncoded();
    } finally {
        //....omitted
    }

上述代码会返回 X.509编译为ASN.1 DER byte[]。现在我们需要在swift中做到这一点。任何人都有任何想法在swift中做到这一点或指向我从哪里开始?

0 个答案:

没有答案