Class: Neo4j::Driver::ClientCertificateManager
- Inherits:
-
Object
- Object
- Neo4j::Driver::ClientCertificateManager
- Defined in:
- lib/neo4j/driver/client_certificate_manager.rb
Overview
Supplies the current client certificate for mutual TLS
(Feature:API:SSLClientCertificate). Wrap a block that returns a
ClientCertificate — or nil when nothing changed since the last call, in
which case the previously supplied certificate is kept. Pass an instance
to GraphDatabase.driver via client_certificate_manager:; the driver
consults it whenever a connection needs a (possibly rotated) certificate.
The MRI counterpart of the Java driver's org.neo4j.driver .ClientCertificateManager (whose get returns null for "no change"); the last non-nil certificate is retained here so a fresh per-connection TLS context always presents the current one.
Instance Method Summary collapse
-
#get_client_certificate ⇒ Object
The current client certificate.
-
#initialize(&get_client_certificate) ⇒ ClientCertificateManager
constructor
A new instance of ClientCertificateManager.
Constructor Details
#initialize(&get_client_certificate) ⇒ ClientCertificateManager
Returns a new instance of ClientCertificateManager.
17 18 19 20 21 |
# File 'lib/neo4j/driver/client_certificate_manager.rb', line 17 def initialize(&get_client_certificate) @get_client_certificate = get_client_certificate @current = nil @mutex = Mutex.new end |
Instance Method Details
#get_client_certificate ⇒ Object
The current client certificate. Polls the block; a non-nil result rotates the retained certificate, a nil result keeps it. Connections are acquired concurrently, so the poll-and-update is serialized: it keeps @current consistent and stops a blocking provider (the testkit callback round-trips to the frontend) from being entered concurrently.
28 29 30 31 32 33 34 |
# File 'lib/neo4j/driver/client_certificate_manager.rb', line 28 def get_client_certificate @mutex.synchronize do certificate = @get_client_certificate.call @current = certificate if certificate @current end end |