【发布时间】:2012-07-17 12:00:20
【问题描述】:
在 iPhone 开发中有没有办法从我的 RSA 公钥 (seckeyref) 生成 X509 证书
或者有谁知道如何将我的公钥传输到 java 服务器?
感谢帕特里克
【问题讨论】:
标签: iphone certificate rsa exchange-server x509
在 iPhone 开发中有没有办法从我的 RSA 公钥 (seckeyref) 生成 X509 证书
或者有谁知道如何将我的公钥传输到 java 服务器?
感谢帕特里克
【问题讨论】:
标签: iphone certificate rsa exchange-server x509
不确定你的意思。如果您的意思是 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() 进行签名,以免违反密钥存储的安全规则。
【讨论】: