File tree Expand file tree Collapse file tree 2 files changed +12
-13
lines changed
lib/elasticsearch/transport
spec/elasticsearch/transport Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ def validate_ca_fingerprints
227
227
ssl = OpenSSL ::SSL ::SSLSocket . new ( socket , ctx )
228
228
ssl . connect
229
229
cert_store = ssl . peer_cert_chain
230
- matching_certs = cert_store . chain . select do |cert |
230
+ matching_certs = cert_store . select do |cert |
231
231
OpenSSL ::Digest ::SHA256 . hexdigest ( cert . to_der ) . upcase == @ca_fingerprint . upcase
232
232
end
233
233
if matching_certs . empty?
Original file line number Diff line number Diff line change 1989
1989
1990
1990
context 'CA Fingerprinting' do
1991
1991
context 'when setting a ca_fingerprint' do
1992
- let ( :subject ) { "/C=BE/O=Test/OU=Test/CN=Test" }
1993
-
1994
1992
let ( :certificate ) do
1995
- OpenSSL ::X509 ::Certificate . new . tap do |cert |
1996
- cert . subject = cert . issuer = OpenSSL ::X509 ::Name . parse ( subject )
1997
- cert . not_before = Time . now
1998
- cert . not_after = Time . now + 365 * 24 * 60 * 60
1999
- cert . public_key = OpenSSL ::PKey ::RSA . new ( 1024 ) . public_key
2000
- cert . serial = 0x0
2001
- cert . version = 2
2002
- end
1993
+ system (
1994
+ 'openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=BE/O=Test/CN=Test"' \
1995
+ ' -keyout certificate.key -out certificate.crt' ,
1996
+ err : File ::NULL
1997
+ )
1998
+ OpenSSL ::X509 ::Certificate . new File . read ( './certificate.crt' )
2003
1999
end
2004
2000
2005
2001
let ( :client ) do
2015
2011
2016
2012
server = double ( 'server' ) . as_null_object
2017
2013
allow ( TCPSocket ) . to receive ( :new ) { server }
2018
- allow_any_instance_of ( OpenSSL ::SSL ::SSLSocket ) . to receive ( :connect ) { nil }
2019
- allow_any_instance_of ( OpenSSL ::SSL ::SSLSocket ) . to receive ( :peer_cert_chain ) { [ certificate ] }
2014
+ socket = double ( 'socket' )
2015
+ allow ( OpenSSL ::SSL ::SSLSocket ) . to receive ( :new ) { socket }
2016
+ allow ( socket ) . to receive ( :connect ) { nil }
2017
+ allow ( socket ) . to receive ( :peer_cert_chain ) { [ certificate ] }
2018
+
2020
2019
response = client . perform_request ( 'GET' , '/' )
2021
2020
expect ( client . transport . connections . connections . map ( &:verified ) . uniq ) . to eq [ true ]
2022
2021
expect ( response ) . to eq 'Hello'
You can’t perform that action at this time.
0 commit comments