Closed ronaldtse closed 2 years ago
It occurred 0004-ssl-certs.patch
contains only certs for the gem install
to work.
Specifying the SSL_CERT_FILE
environment variable for rubyc
helps with the issue, so I see the following options:
SSL_CERT_FILE
is used and provide a path thereIt would certainly be better to use SSL_CERT_FILE
to run this. Maybe when we start up the application we just set ENV['SSL_CERT_FILE']
to point to a file on the memfs?
Found a third solution: to provide --openssldir
when compiling openssl
, but seems it doesn't work.
Let's set the SSL_CERT_FILE
variable in the main patch.
Though the openssldir
option works, and it changes the OpenSSL::X509::DEFAULT_CERT_FILE
constant properly, but it still didn't work.
The same with SSL_CERT_FILE
. It doesn't work with paths from memfs. Seems that openssl
calls to file system should be patched to fix this issue.
Finally it works when the cert is read from memfs with Ruby and provided for the openssl
lib as a string. It is done by using OpenSSL::X509::Certificate.
So now calls with Net::HTTP
work properly:
$ RUBY_PACKER_USE_ORIGINAL_RUBY=1 ./rubyc-linux-x64 -e 'require "net/http"; puts Net::HTTP.get(URI("https://github.com/fontist/source-fonts/releases/download/v1.0/source-fonts-1.0.zip"))'
That's excellent -- @alexeymorozov if this code can be merged that would be great, and this issue can be closed. Thanks!
In packed-mn, we had to make this hack: https://github.com/metanorma/packed-mn/blob/c1904865ca7e5375ecb4acbf2e5e86fe682ebb9f/bin/metanorma#L178-L186
And supply our own CA file (from cURL which uses Mozilla's: https://curl.se/ca/cacert.pem).
This should not be necessary given that we already have this patch: https://github.com/metanorma/ruby-packer/blob/master/.patches/ruby/0004-ssl-certs.patch
Without this hack, we get these errors:
https://github.com/metanorma/packed-mn/runs/4454422319?check_suite_focus=true
https://github.com/metanorma/packed-mn/runs/4454422376?check_suite_focus=true