File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ gitlab_url: "http://localhost/"
77http_settings:
88# user: someone
99# password: somepass
10+ # ca_file: /etc/ssl/cert.pem
11+ # ca_path: /etc/pki/tls/certs
1012 self_signed_cert: false
1113
1214# Repositories path
Original file line number Diff line number Diff line change @@ -42,10 +42,14 @@ def host
4242 def get ( url )
4343 url = URI . parse ( url )
4444 http = Net ::HTTP . new ( url . host , url . port )
45- http . use_ssl = ( url . scheme == 'https' )
4645
47- if config . http_settings [ 'self_signed_cert' ] && http . use_ssl?
48- http . verify_mode = OpenSSL ::SSL ::VERIFY_NONE
46+ if URI ::HTTPS === url
47+ http . use_ssl = true
48+ http . cert_store = cert_store
49+
50+ if config . http_settings [ 'self_signed_cert' ]
51+ http . verify_mode = OpenSSL ::SSL ::VERIFY_NONE
52+ end
4953 end
5054
5155 request = Net ::HTTP ::Get . new ( url . request_uri )
@@ -55,4 +59,18 @@ def get(url)
5559
5660 http . start { |http | http . request ( request ) }
5761 end
62+
63+ def cert_store
64+ @cert_store ||= OpenSSL ::X509 ::Store . new . tap { |store |
65+ store . set_default_paths
66+
67+ if ca_file = config . http_settings [ 'ca_file' ]
68+ store . add_file ( ca_file )
69+ end
70+
71+ if ca_path = config . http_settings [ 'ca_path' ]
72+ store . add_path ( ca_path )
73+ end
74+ }
75+ end
5876end
You can’t perform that action at this time.
0 commit comments