文件安全传输服务器,安全传输:从文件加载服务器证书
如果兩個(gè)文件都可以進(jìn)行分組并轉(zhuǎn)換為pkcs 12格式,則可以使用SecPKCS12Import方法。
但是SecPKCS12Import在根上下文中無法正常工作。我不知道這種不端行為的原因。
OSStatus extractIdentityAndTrust(CFDataRef inPKCS12Data,
SecIdentityRef *outIdentity,
SecTrustRef *outTrust,
CFStringRef keyPassword)
{
OSStatus securityError = errSecSuccess;
const void *keys[] = { kSecImportExportPassphrase };
const void *values[] = { keyPassword };
CFDictionaryRef optionsDictionary = NULL;
optionsDictionary = CFDictionaryCreate(
NULL, keys,
values, (keyPassword ? 1 : 0),
NULL, NULL);
CFArrayRef items = NULL;
securityError = SecPKCS12Import(inPKCS12Data,
optionsDictionary,
&items);
if (securityError == 0)
{
CFDictionaryRef myIdentityAndTrust = (CFDictionaryRef)CFArrayGetValueAtIndex (items, 0);
const void *tempIdentity = NULL;
tempIdentity = CFDictionaryGetValue (myIdentityAndTrust,
kSecImportItemIdentity);
CFRetain(tempIdentity);
*outIdentity = (SecIdentityRef)tempIdentity;
const void *tempTrust = NULL;
tempTrust = CFDictionaryGetValue (myIdentityAndTrust, kSecImportItemTrust);
CFRetain(tempTrust);
*outTrust = (SecTrustRef)tempTrust;
}
if (optionsDictionary)
CFRelease(optionsDictionary);
if (items)
CFRelease(items);
return securityError;
}
阿南德
總結(jié)
以上是生活随笔為你收集整理的文件安全传输服务器,安全传输:从文件加载服务器证书的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 请检查网站服务器是否正常.,网站访问不了
- 下一篇: 2020 我的C++的学习之路