相关疑难解决方法(0)

SecKeyRawVerify和OSError -9809

我正在使用数字证书在我的应用程序中签署数据文件.当SecKeyRawVerify使用-9809返回调用时,下面的代码片段失败.这是在iPhone上运行.我甚至无法准确确定此错误代码的含义

先前的安全框架调用加载并创建SecTrustRef,从中获取公钥似乎没问题 - 没有错误.唯一的小问题是调用SecTrustEvaluate返回a kSecTrustResultUnspecified,但我认为这是因为我使用的策略是SecPolicyCreateBasicX509调用返回的样板.

非常感谢任何帮助或见解.

谢谢

SecKeyRef keyRef = SecTrustCopyPublicKey (trustRef);

fileURL = [[NSBundle mainBundle] URLForResource:@"data" withExtension:@"txt"];
NSData *data = [NSData dataWithContentsOfURL:fileURL];

fileURL = [[NSBundle mainBundle] URLForResource:@"data" withExtension:@"sgn"];
NSData *signature = [NSData dataWithContentsOfURL:fileURL];

NSLog(@"Hash block size = %zu",SecKeyGetBlockSize(keyRef));

status = SecKeyRawVerify (keyRef,
                          kSecPaddingPKCS1SHA1,
                          (const uint8_t *)[data bytes],
                          (size_t)[data length],
                          (const uint8_t *)[signature bytes],
                          (size_t)[signature length]
                          );
Run Code Online (Sandbox Code Playgroud)

objective-c security-framework ios

7
推荐指数
1
解决办法
4084
查看次数

标签 统计

ios ×1

objective-c ×1

security-framework ×1