如何在raspberry pi上验证openssl证书?

时间:2018-05-19 00:24:21

标签: ssl openssl raspberry-pi ssl-certificate digital-signature

我正在使用覆盆子pis创建一个测试网络。我的电脑将是CA和我的客户端。我在计算机上创建了自签名CA证书,在pi上创建了证书请求,并使用计算机上的CA密钥对请求进行了签名。

当我在pi上验证证书时,出现错误。使用相同命令和相同文件的计算机上没有错误

树莓派上的错误:

$ openssl verify -verbose -CAfile ca.pem pi.pem
error 18 at 0 depth lookup: self signed certificate
error cert.pem: verification failed
# ca.pem is the ca self-signed cert. pi.pem is the cert signed by ca private key

使用计算机上的SAME文件:

$ openssl verify -verbose -CAfile ca.pem pi.pem
error cert.pem: verification failed
error 18 at 0 depth lookup: self signed certificate
OK
# ca.pem is the ca self-signed cert. pi.pem is the cert signed by ca private key

到目前为止我尝试了什么

  1. 在pi上重新安装openssl
  2. 将openssl.cnf文件替换为pi上的文件与计算机上的文件
  3. 改变了覆盆子pi的时间
  4. 切换角色:pi作为CA,计算机作为客户端。这导致验证在计算机上工作,但不是pi(如前所述)
  5. raspbian版是伸展不太阳
  6. 尝试过自签名证书验证。验证是否适用于计算机和pi。
  7. 创建证书的过程:

    # Server: https://support.symantec.com/en_US/article.TECH242030.html
    openssl req -new -sha256 -out cert.csr
    openssl x509 -req -days 365 -in cert.csr -signkey privkey.pem -sha256 -out cert.crt
    openssl x509 -in cert.crt -out ca.pem -outform PEM
    
    # Client:
    openssl req -new -sha256 -out pi.csr
    openssl x509 -req -days 365 -in pi.csr -signkey privkey.pem -sha256 -out pi.crt # <--- privkey.pem is the privkey of CA
    openssl x509 -in pi.crt -out pi.pem -outform PEM
    

1 个答案:

答案 0 :(得分:1)

您需要某种CA证书配置文件,否则它将使用basicConstraints=CA:FALSE,这意味着它会创建自签名叶证书而不是CA证书。换句话说,您的证书是受信任的,但不是用于签署其他证书

参见例如这里是如何创建一个链。

https://gist.github.com/Soarez/9688998

请注意,您还需要使用例如-CA-CAkey所以请不要使用您自己的命令,而只是配置文件。