I cannot connect to a remote server using SSL.
I’m trying to connect to an AMQP1.0 server using rabbitmq-server/deps/amqp10_client/src at main · rabbitmq/rabbitmq-server · GitHub
I can connect using Python + qpid-proton using a certificate. I can also establish a secure connection using the following command with the same certificate file:
$ openssl s_client -connect 7.7.7.7:7777 -CAfile key.crt.pem
...
Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:RSA-PSS+SHA256:RSA-P
SS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384
:RSA+SHA512:DSA+SHA256:ECDSA+SHA224:RSA+SHA224:DSA+SHA224:ECDSA+SHA1:RSA+SHA1:DSA+SHA1
Shared Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:RSA-PSS+SHA25
6:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA
+SHA384:RSA+SHA512:DSA+SHA256:ECDSA+SHA224:RSA+SHA224:DSA+SHA224
---
SSL handshake has read 11966 bytes and written 667 bytes
Verification: OK
---
New, TLSv1.2, Cipher is AES256-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : AES256-SHA256
Session-ID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Session-ID-ctx:
Master-Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1682342266
Timeout : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: yes
---
However, I cannot do the same with Erlang/Elixir. The simplest Elixir code I can create that replicate the error is the following:
opts = [
cacertfile: './key.crt.pem',
verify: :verify_peer,
server_name_indication: :disable,
ciphers: [:ssl.str_to_suite('AES256-SHA256')]
# ciphers: [:ssl.str_to_suite('TLS_RSA_WITH_AES_256_CBC_SHA256')]
]
:ssl.connect({7, 7, 7, 7}, 7777, opts)
And I have the following error:
Connecting: {:error,
{:shutdown,
{:failed_to_start_child, :reader,
{:tls_alert,
{:unknown_ca,
'TLS client: In state certify at ssl_handshake.erl:2111 generated CLIENT ALERT: Fatal
- Unknown CA\n'}}}}}
** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_c
hild, :reader, {:tls_alert, {:unknown_ca, 'TLS client: In state certify at ssl_handshake.er
l:2111 generated CLIENT ALERT: Fatal - Unknown CA\n'}}}}}
I’m using Erlang 25.3 (Elixir 1.14.3) but I tried other versions with similar results. I also tried TLS_RSA_WITH_AES_256_CBC_SHA256
cipher because it is the one that the Python client uses with similar results.
I don’t have any clue to solve this problem. Any idea?
I really appreciate any help you can provide.