此代码导入证书成功,但使用旧密码。
guard let secCert = SecCertificateCreateWithData(nil, certData) else {
completion(false)
return
}
var query: [String: Any] = [
kSecClass as String: kSecClassCertificate,
kSecValueRef as String: secCert,
kSecAttrLabel as String: alias,
]
SecItemDelete(query as CFDictionary)
var addStatus: OSStatus = SecItemAdd(query as CFDictionary, nil)
我需要在SecItemAdd之前更改证书密码。我尝试添加到查询:
query[kSecImportExportPassphrase as String] = newPassword
但它返回-50。
请帮帮我吗?
谢谢
答案 0 :(得分:0)
我通过PKCS12import检查密码是否匹配,然后使用新密码创建新的p12文件。在此之后,我将证书导入了钥匙串。