I know I can choose to verify the client with --ssl-verify, but how can I specify which CA chain that I want to use? I’m used to providing a file (like with curl’s --cacert or WEBrick’s :SSLCACertificateFile), so I’ve got one ready, but I can’t seem to find documentation on how to pass it to thin.
I know I can choose to verify the client with –ssl-verify , but how
Share
Short answer: You can’t.
Long answer: You could, but you’d have to update EventMachine’s C++ extension that builds the ssl connection, and update the call stack up through EventMachine and Thin to pass the certificate authority file along.
How I found this out: Source Code! It’s all on github
thin’s command line opts are parsed in
thin:lib/thin/runner.rband then used to create a controller
In
thin:lib/controllers/controller.rbthe ssl options are pulled back out to be stored with the server objectand are finally used to initialize the connection to the client
This connection is an
EventMachine::Connection, defined ineventmachine:lib/em/connection.rb.EventMachine::Connection#start_tlspasses the parameters along toEventMachine::set_tls_parms.EventMachine::set_tls_parmsis part of the C++ extension and is defined ineventmachine:ext/rubymain.cppas the five argument C functiont_set_tls_parmsAnd
t_set_tls_parmsdefined elsewhere in the same file just passes the ssl options on toevma_set_tls_parms.The vanilla C function
evma_set_tls_parmsis defined ineventmachine:ext/cmain.cpp. It passes the ssl options on toEventableDescriptor‘sSetTlsParmsmethod:That
SetTlsParmsinstance method is defined ineventmachine:ed.cpp, and all it really does is cache the ssl options in some instance variables.Those instance variables are used later in the
StartTlsinstance method (defined in the same file), and passed on to initialize a newSslBox_tThe
SslBox_tconstructor is defined ineventmachine:ext/ssl.cpp, where it uses the ssl options to initialize a newSslContext_t.The
SslContext_tconstructor is defined in the same file where it uses those options with the standard OpenSSL C bindings:So now we know how the ssl options are used. If the call chain were modified to pass a CA file name along with the rest down to this point, say as
const string &certauthfile, we could use just a couple more OpenSSL calls to add the authority file:Submitting a patch to do this is left as an exercise for the sufficiently motivated.