Skip to content

Commit 8043444

Browse files
authored
Gracefully handle the case where the issuer can't be found (#2946)
1 parent 842b794 commit 8043444

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/mongo/socket/ssl.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Socket
2323
# @since 2.0.0
2424
class SSL < Socket
2525
include OpenSSL
26+
include Loggable
2627

2728
# Initializes a new TLS socket.
2829
#
@@ -455,13 +456,16 @@ def verify_certificate!(socket)
455456
end
456457

457458
def verify_ocsp_endpoint!(socket, timeout = nil)
458-
unless verify_ocsp_endpoint?
459-
return
460-
end
459+
return unless verify_ocsp_endpoint?
461460

462461
cert = socket.peer_cert
463462
ca_cert = find_issuer(cert, socket.peer_cert_chain)
464463

464+
unless ca_cert
465+
log_warn("TLS certificate of '#{host_name}' could not be definitively verified via OCSP: issuer certificate not found in the chain.")
466+
return
467+
end
468+
465469
verifier = OcspVerifier.new(@host_name, cert, ca_cert, context.cert_store,
466470
**Utils.shallow_symbolize_keys(options).merge(timeout: timeout))
467471
verifier.verify_with_cache

0 commit comments

Comments
 (0)