【问题标题】:How to print the public key of a certificate (Objective-C)如何打印证书的公钥(Objective-C)
【发布时间】:2011-01-08 05:00:47
【问题描述】:

我有一个 .p12 和 .crt 证书,我想存储公钥以打印它并将该密钥用于 iPhone 应用程序。我看过iPhone的文档,但是我做不到……

【问题讨论】:

    标签: iphone objective-c certificate


    【解决方案1】:

    这非常容易。您无需将证书添加到钥匙串即可处理这种情况。相反,只需在您的应用程序中加载证书数据(即 .cer 文件的内容)(您可以从捆绑包中或从网络中获取),然后使用 SecCertificateCreateWithData 创建证书引用。从那里您可以使用 SecTrust 对象(SecTrustCreateWithCertificates、SecTrustEvaluate - 您可以选择忽略生成的 SecTrustResultType - 和 SecTrustCopyPublicKey)提取公钥引用。从那里您可以使用 SecKey API(SecKeyEncrypt、SecKeyRawVerify)进行加密和验证。

    https://devforums.apple.com/message/114555#114555

    【讨论】:

      猜你喜欢
      • 2012-04-23
      • 2019-10-30
      • 2021-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-18
      • 2019-03-17
      相关资源
      最近更新 更多