【问题标题】:How to find the certificate added with SecItemAdd in Keychain如何在 Keychain 中找到使用 SecItemAdd 添加的证书
【发布时间】:2019-12-14 05:27:59
【问题描述】:

apple's doc 之后,我编写了这段代码来将证书添加到我在 macOS 上的登录钥匙串中

let certUrl = Bundle.main.url(forResource: "cert", withExtension: "cer")!
let certData = try! Data(contentsOf: certUrl)
let cert = SecCertificateCreateWithData(nil, certData as CFData)!
let addQuery: [String: Any] = [
    kSecClass as String: kSecClassCertificate,
    kSecValueRef as String: cert,
    kSecAttrLabel as String: "My Certificate"
]
let status = SecItemAdd(addQuery as CFDictionary, nil)
guard status == errSecSuccess else {
    print(status)
    return true
}
print("cert added")
return true

有效,但问题是当我打开钥匙串访问应用程序时,我在登录钥匙串的证书类别中找不到添加的证书。

我尝试再次运行代码,但由于重复证书错误而失败。所以必须添加证书。我想知道如何在钥匙串访问中找到它?或者使用 SecItemAdd 添加的证书总是对 Keychain Access 应用程序隐藏?

macOS 版本:10.15.1

【问题讨论】:

    标签: ios macos cocoa certificate


    【解决方案1】:

    我使用的是 Mac Catalyst。切换到可可应用程序使其工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-14
      • 2013-01-03
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      • 2020-03-04
      • 1970-01-01
      相关资源
      最近更新 更多