File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ # Remove this module from LOAD_PATH, so we can load the real one
2+ gem_override_path = File . expand_path ( '..' , __dir__ ) # parent dir, we're a subfolder
3+ $LOAD_PATH. reject! { |path | File . expand_path ( path ) == gem_override_path }
4+
5+ # Override net/http, the built-in HTTP module to inject our cert
6+ # This isn't necessary with OpenSSL (doesn't hurt), but LibreSSL ignores
7+ # the SSL_CERT_FILE setting, so we need to be more explicit:
8+ require 'net/http'
9+ module Net
10+ module HTTPHttpToolkitExtensions
11+ def ca_file = ( path )
12+ # If you try to use a certificate, use ours instead
13+ super ( ENV [ 'SSL_CERT_FILE' ] )
14+ end
15+
16+ def cert_store = ( store )
17+ # If you try to use a whole store of certs, use ours instead
18+ self . ca_file = ENV [ 'SSL_CERT_FILE' ]
19+ end
20+
21+ def use_ssl = ( val )
22+ # If you try to use SSL, make sure you trust our cert first
23+ self . ca_file = ENV [ 'SSL_CERT_FILE' ]
24+ super ( val )
25+ end
26+ end
27+
28+ class HTTP
29+ prepend HTTPHttpToolkitExtensions
30+ end
31+ end
32+
33+ # Put this override directory back on LOAD_PATH
34+ $LOAD_PATH. unshift ( gem_override_path )
You can’t perform that action at this time.
0 commit comments