-
Or mtls - where client present to server it's ssl certificate and then server validates this certificate before processing request, or gives me possiblity to do validation? |
Beta Was this translation helpful? Give feedback.
Answered by
ioquatix
Jan 25, 2025
Replies: 1 comment 2 replies
-
Yes, it should be possible, but it may require some effort. In the first instance, here is an example of how to do client validation of the server: require 'async'
require 'async/http'
# These are generated from the certificate chain that the server presented.
trusted_fingerprints = {
"dac9024f54d8f6df94935fb1732638ca6ad77c13" => true,
"e6a3b45b062d509b3382282d196efe97d5956ccb" => true,
"07d63f4c05a03f1c306f9941b8ebf57598719ea2" => true,
"e8d994f44ff20dc78dbff4e59d7da93900572bbf" => true,
}
Async do
endpoint = Async::HTTP::Endpoint.parse("https://www.codeotaku.com/index")
# This is a quick hack/POC:
ssl_context = endpoint.ssl_context
ssl_context.verify_callback = proc do |verified, store_context|
certificate = store_context.current_cert
fingerprint = OpenSSL::Digest::SHA1.new(certificate.to_der).to_s
if trusted_fingerprints.include? fingerprint
true
else
Console.warn("Untrusted Certificate Fingerprint", fingerprint: fingerprint)
false
end
end
endpoint = endpoint.with(ssl_context: ssl_context)
client = Async::HTTP::Client.new(endpoint)
response = client.get(endpoint.path)
pp response.status, response.headers.fields, response.read
end I believe a similar approach can be used on the server (e.g. Falcon). Do you have something specific in mind for |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a small example for setting up
falcon host
using a verify_callback: