mongodb icon indicating copy to clipboard operation
mongodb copied to clipboard

ssl_opts - what are the various options?

Open jschorr opened this issue 8 years ago • 5 comments

Can anyone please tell me what the various options for ssl_opts can be? I have a Production replica set that uses various SSL options in /etc/mongod.conf.

screenshot from 2018-08-30 15-46-15

I get the following: mix phx.server Compiling 1 file (.ex) [info] Running SecureProcessorWeb.Endpoint with Cowboy using http://0.0.0.0:14000 [info] ['TLS', 32, 'client', 58, 32, 73, 110, 32, 115, 116, 97, 116, 101, 32, 'hello', 32, 'received SERVER ALERT: Fatal - Handshake Failure', 10] [info] ['TLS', 32, 'client', 58, 32, 73, 110, 32, 115, 116, 97, 116, 101, 32, 'hello', 32, 'received SERVER ALERT: Fatal - Handshake Failure', 10] [info] ['TLS', 32, 'client', 58, 32, 73, 110, 32, 115, 116, 97, 116, 101, 32, 'hello', 32, 'received SERVER ALERT: Fatal - Handshake Failure', 10] [error] Mongo.Protocol (#PID<0.317.0>) failed to connect: ** (Mongo.Error) ssl connect: TLS Alert: handshake failure - {:tls_alert, 'handshake failure'} My connection works fine against a replica set without SSL but I can't turn that off on in Production. I can't seem to find ssl_opts documented anywhere (here or Google). screenshot from 2018-08-30 15-49-23

jschorr avatar Aug 30 '18 20:08 jschorr

I may have gotten furthre by using the following (after checking erlang ssl docs):

          [cacertfile: "/etc/ssl/ca.pem"],
          [certfile: "/etc/ssl/mongodb.pem"],
	  [keyfile: "/etc/ssl/mongodb.pem"],
          [tls_versions: ["tlsv1.2"]],
          [verify_type: "verify_none"]]

resulting in 2018-08-30T19:00:07.489-0400 E NETWORK [conn21254] SSL: error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher - not sure why SSL3 is being sent. Also tried specifying a list of ciphers to no avail.

jschorr avatar Aug 30 '18 23:08 jschorr

You probably do not want to wrap each of those in its own list. you will probably want the following instead.

ssl_opts: [cacertfile: "...", certfile: "...", ...]

You may also want to double check some of your keys and values.

  • tls_versions is not a valid key, I think you meant versions
  • verify_type is not a valid key, I think you meant verify
  • "verify_none" is not a valid value, it should be an atom
  • ["tlsv1.2"] is not avalid value, it should be a list of atoms ([:"tlsv1.2"])

ankhers avatar Aug 31 '18 01:08 ankhers

Thank you for clarifying. I still get the SSL: error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher error, unfortunately. My config now looks like:

        ssl_opts: [
          cacertfile: "/etc/ssl/ca.pem",
          certfile: "/etc/ssl/mongodb.pem",
          cipher: :"ECDHE-RSA-AES128-GCM-SHA256",
          honor_cipher_order: true,
          keyfile: "/etc/ssl/mongodb.pem",
          server_renegotiate: true,
          verify: :verify_none
          versions: [:"tlsv1.2"]
        ]```

The cipher is what openssl says is supported with the cert.  I've tried with and without that line (and the one following it).

jschorr avatar Aug 31 '18 14:08 jschorr

Please reread the Erlang ssl module documentation. The key :cipher does not exist. It is :ciphers. And :"ECDHE-RSA-AES128-GCM-SHA256" is an invalid value.

ankhers avatar Aug 31 '18 18:08 ankhers

Did you manage to solve this issue ? I am having exactly the same at the moment. Elixir version is 1.6 and OTP 21. Cheers.

norman-forti avatar Sep 28 '18 07:09 norman-forti