因此我们在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中做到这一点或指向我从哪里开始?