繁体   English   中英

iPhone从RSA公钥生成X509证书

[英]iPhone generate X509 certificate from RSA public key

iPhone开发中是否有办法从我的RSA公钥(seckeyref)生成X509证书

还是有人知道我如何将我的公钥传输到Java服务器?

谢谢帕特里克

不明白你的意思。 如果您指的是RSA完整证书,则:

SecCertificateRef cert = ...
CFDataRef der = SecCertificateCopyData(cert);

const unsigned char * ptr = CFDataGetBytePtr(der);
int len = CFDataGetLength(der);

// now write len bytes from ptr to a file, put it in a POST request
// to the server, etc.

您可以将其写成二进制文件(作为DER文件),也可以将其转换为base64作为PEM证书。 Java将喜欢DER文件/格式并接受

FileInputStream certificateStream = new FileInputStream(aboveDerFileOrPost);
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
java.security.cert.Certificate[] certs = {};
certs = certificateFactory.generateCertificates(certificateStream).toArray();
certificateStream.close();

某种方式。 如果您的意思是您拥有原始的RSA公钥-现在您想添加X509内容以使其成为证书,然后对其进行签名-则需要做很多工作。 AFAIK需要使用openssl(或者至少是我这样做的方式)来创建x509结构; 然后使用SecTransformExecute()或SecKeyRawSign()进行签名,以免违反密钥存储区上的安全规则。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM