通过 ssl 进行路边柱

发布于 2024-12-28 23:09:18 字数 458 浏览 0 评论 0原文

如何使用遏制红宝石宝石通过 https 发布帖子?

这就是我通过 http 将文件发布到服务器的方法:

c = Curl::Easy.new("http://www.myserver.com/upload_messages")
c.multipart_form_post = true
post_field = Curl::PostField.content('fieldname', myfile)
c.http_post(post_field) 

使用 net::http 我会使用 use_ssl = true 但如何使用遏制来做到这一点?

这篇文章转到了在heroku上运行的应用程序,我现在得到的错误是:

Curl::Err::SSLCaertBadFile (Curl::Err::SSLCaertBadFile)

谢谢。

how can you do a post over https using curb ruby gem?

This is how I do it over http to post a file to a server:

c = Curl::Easy.new("http://www.myserver.com/upload_messages")
c.multipart_form_post = true
post_field = Curl::PostField.content('fieldname', myfile)
c.http_post(post_field) 

With net::http I would use use_ssl = true but how to do it with curb?

The post goes to an application running on heroku and the error I get now is:

Curl::Err::SSLCaertBadFile (Curl::Err::SSLCaertBadFile)

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷情 2025-01-04 23:09:18

您是否尝试过 c = Curl::Easy.new("https://www.myserver.com/upload_messages") (请注意网址上的 https 而不是 http),因为在此示例中( https://github.com/taf2/curb/blob/master/samples/gmail.rb)来自 Curb 的 Github(我认为可行,我自己还没有尝试过),他们发布通过 https 发送到 Gmail 就可以了。

Have you tried c = Curl::Easy.new("https://www.myserver.com/upload_messages") (note the https instead of http on the url), cause in this example (https://github.com/taf2/curb/blob/master/samples/gmail.rb) from Curb's Github (that I suppose works, haven't tried it myself) they post to Gmail through https just doing that.

怎会甘心 2025-01-04 23:09:18

看来您的证书有问题,应该有信任未签名的选项。

require 'net/http'
require 'net/https'
require 'uri'

url = URI.parse 'https://myname:[email protected]/'
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.scheme == 'https')
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

还可以尝试 curb-fu gem。在那里你可以像这样发出 ssl post 请求

form_data = { :color => 'red', :shape => 'sphere' }
response = CurbFu.post({:url => "https://example.com", :protocol => "https"}, form_data)

It seems that you have bad certificates and there should be option to trust unsigned.

require 'net/http'
require 'net/https'
require 'uri'

url = URI.parse 'https://myname:[email protected]/'
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.scheme == 'https')
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

Also try curb-fu gem. There you can make ssl post request like

form_data = { :color => 'red', :shape => 'sphere' }
response = CurbFu.post({:url => "https://example.com", :protocol => "https"}, form_data)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文