【问题标题】:Error while converting public key in pem format to der format in terminal in mac在mac终端中将pem格式的公钥转换为der格式时出错
【发布时间】:2015-10-19 23:26:59
【问题描述】:

我已经在 mac 中使用终端为 SSL 连接创建了公钥对。我使用以下命令创建私钥并从中提取公钥:

# Create public-private key pair
openssl genrsa -out mykey.cer 1024

# Extract public key
openssl rsa -in mykey.cer -out public.pem -outform PEM -pubout

现在要在我的 iPhone 应用程序中使用公钥,我需要将其转换为 der 格式。但是当我尝试使用以下命令转换它时,我收到了一个错误:

openssl x509 -in public.pem -outform der -out cert.der
**unable to load certificate
27928:error:0906D06C:PEM routines:PEM_read_bio:no start line:/SourceCache/OpenSSL098/OpenSSL098-52.20.2/src/crypto/pem/pem_lib.c:648:Expecting: TRUSTED CERTIFICATE**

我正在使用this link 创建与服务器的 SSL 连接。

【问题讨论】:

    标签: ios macos ssl encryption


    【解决方案1】:

    我相信将公钥从 PEM 格式转换为 DER 格式的命令是

    openssl rsa -pubin -in public.pem -outform der -out cert.der
    

    (您选择的输出文件名 cert.der 具有误导性。它是公钥,而不是证书,public.der 会更好)

    【讨论】:

      猜你喜欢
      • 2013-04-12
      • 1970-01-01
      • 2020-01-28
      • 1970-01-01
      • 2022-06-30
      • 2011-07-20
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      相关资源
      最近更新 更多