1

私の RSA 公開鍵 (seckeyref) から X509 証明書を生成する iPhone 開発の方法はありますか?

または、公開鍵をJavaサーバーに送信する方法を知っている人はいますか?

ありがとうパトリック

4

1 に答える 1

0

よく分からない。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ファイルとして)書き出すか、PEM証明書としてbase64に変換できます。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 のものを追加してそれを証明書にしてから署名したい場合、それはかなりの作業です。そして、x509構造を作成するためにopensslを使用する必要があるAFAIK(または少なくともそれが私のやり方です)。次に、SecTransformExecute() または SecKeyRawSign() を使用して署名し、キー ストアのセキュリティ ルールに違反しないようにします。

于 2012-07-18T14:31:01.947 に答える