如何使用iOS中的公鑰驗證數字簽名而不使用任何第三方代碼(例如)打開SSL?使用iOS中的公鑰驗證數字簽名
我需要使用公鑰驗證iOS應用程序中的數字簽名。有人可以幫助我如何在不使用第三方軟件的情況下實現這一目標。
我想下面的代碼,但問題是我沒有證書在我的應用程序,所以不能創建SecTrustRef。
CODE:
NSString *certPath = [[NSBundle mainBundle] pathForResource:@"yyy"
ofType:@"xxx"];
SecCertificateRef myCertificate = nil;
NSData *certificateData = [[NSData alloc] initWithContentsOfFile :certPath];
myCertificate = SecCertificateCreateWithData(kCFAllocatorDefault, (__bridge CFDataRef)certificateData);
SecPolicyRef myPolicy = SecPolicyCreateBasicX509();
SecTrustRef trustRef;
SecTrustCreateWithCertificates(myCertificate, myPolicy, &trustRef);
SecKeyRef keyRef = SecTrustCopyPublicKey (trustRef);
BOOL status = SecKeyRawVerify (keyRef,
kSecPaddingPKCS1SHA1,
(const uint8_t *)[data bytes],
(size_t)[data length],
(const uint8_t *)[signature bytes],
(size_t)[signature length]
);
我有以下幾點:
- 公鑰(的NSString *)
- 簽名(的NSString *)
- 數據(的NSString *)
請幫助我在iOS中擁有的所有選項SDK如果我不想使用螞蟻第三方開源。
如果我的答案幫助了您,請接受此問題將標記爲已解決並幫助其他用戶。謝謝 – mindbomb 2014-05-28 14:50:03
你有沒有得到一些解決方案,或者你創建.pem? – DivineDesert 2015-10-26 06:40:19