ocsp通过传递证书文本而不是文件来验证证书

时间:2015-02-20 23:46:48

标签: ruby-on-rails ruby ssl openssl ocsp

我正在尝试针对ocsp响应者运行我的证书以检查其有效性。 我在rails上使用Ruby,但基本上将其作为系统命令运行

目前,以下命令可以运行并将结果存储在文件中。

command = "openssl ocsp -issuer #{Rails.root}/ca-cert.crt -cert #{Rails.root}/"+@filename+".crt -CAfile #{Rails.root}/ca-cert.crt -url "+CONFIG[:ocsp_responder] +" > " + outputfile"
system(command)

但是我没有传递" @ filename.crt",而是想传递public_certificate本身。那个适当的语法是什么?

我尝试了以下内容:

 command = "openssl ocsp -issuer #{Rails.root}/cert/ca-cert.crt -cert #{cert} -CAfile #{Rails.root}/data/certs/ca-cert.crt -url "+CONFIG[:ocsp_responder] +" > " + outputfile
# cert = the certificate in text --BEGIN..blah blah.--END

这不起作用。是否有替代方案而无需指定公共证书文件?

1 个答案:

答案 0 :(得分:0)

老实说,我不相信命令行openssl客户端以任何形式接受证书作为字符串,假设你想做类似的事情:
cert = request.env['VAR_WITH_CERT]

你可能需要通过一些临时文件。