【发布时间】:2015-09-08 13:22:08
【问题描述】:
如何用 ruby on rails 编写这段代码?
curl -k --cert path/cert.cer --key path/private.key -F "file=path/pkcs7.file" https://server.com/test > resp.txt
更新: 我用过宝石路边,我的解决方案:
http = Curl.post("https://server.com/test", signed_data) do|http|
http.cert = "path/included_key.pem" # in linux: cat path/cert.cer path/private.key > path/included_key.pem, more info http://stackoverflow.com/questions/991758/how-to-get-an-openssl-pem-file-from-key-and-crt-files
http.certpassword = '198512' # is optional
http.headers["Content-Type"] = 'application/pkcs7-mime' # is optional, needs for me
http.ssl_verify_peer = false # is equal -k flag in curl
end
Rails.logger.info http.body_str
【问题讨论】:
-
rails 是一个框架。你不能在rails中编码。您可以使用 net:http 库在 ruby 中编写代码
-
脚本是我写的,你可以在主题中看到
-
好。那么你现在的问题是什么?如何将结果保存在文本文件中?
-
我想写一个简单地接收数据的脚本。我的问题已经结束。谢谢
标签: bash ruby-on-rails-4 curl