我已经在 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 连接。
最佳答案
我相信将公钥从 PEM 格式转换为 DER 格式的命令是
openssl rsa -pubin -in public.pem -outform der -out cert.der
(您选择的输出文件名 cert.der 具有误导性。它是公钥,而不是证书,public.der 会更好)
关于ios - 在 mac 终端中将 pem 格式的公钥转换为 der 格式时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31692708/