Module: SourceMonitor::HTTP::AIAResolver
- Defined in:
- lib/source_monitor/http/aia_resolver.rb
Constant Summary collapse
- CONNECT_TIMEOUT =
5- DOWNLOAD_TIMEOUT =
5- CACHE_TTL =
1 hour
3600
Class Method Summary collapse
- .cache_size ⇒ Object
- .clear_cache! ⇒ Object
- .enhanced_cert_store(additional_certs) ⇒ Object
- .resolve(hostname, port: 443) ⇒ Object
Class Method Details
.cache_size ⇒ Object
51 52 53 |
# File 'lib/source_monitor/http/aia_resolver.rb', line 51 def cache_size @mutex.synchronize { @cache.size } end |
.clear_cache! ⇒ Object
47 48 49 |
# File 'lib/source_monitor/http/aia_resolver.rb', line 47 def clear_cache! @mutex.synchronize { @cache.clear } end |
.enhanced_cert_store(additional_certs) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/source_monitor/http/aia_resolver.rb', line 34 def enhanced_cert_store(additional_certs) store = OpenSSL::X509::Store.new store.set_default_paths Array(additional_certs).each do |cert| store.add_cert(cert) rescue OpenSSL::X509::StoreError # Already in store or invalid -- skip end store end |
.resolve(hostname, port: 443) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/source_monitor/http/aia_resolver.rb', line 15 def resolve(hostname, port: 443) cached = cache_lookup(hostname) return cached if cached cert = fetch_leaf_certificate(hostname, port) return unless cert url = extract_aia_url(cert) return unless url intermediate = download_certificate(url) return unless intermediate cache_store(hostname, intermediate) intermediate rescue StandardError nil end |