iPhone从RSA公钥生成X509证书



在iPhone开发中有没有一种方法可以从我的RSA公钥(seckeyref)生成X509证书

或者有人知道我如何将公钥传输到java服务器吗?

感谢Patrick

不知道你的意思。若你们的意思是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()进行签名,以免违反密钥存储上的安全规则。

最新更新