# openssl s_client -connect localhost:5671 -cert /etc/ssl/rabbitmq/server.rabbitmq.pem -key /etc/ssl/rabbitmq/server.rabbitmq-key.pem -CAfile /etc/ssl/rabbitmq/knl-backend-chain-ca.pem CONNECTED(00000003)
write:errno=104
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 293 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
--- import socket
import ssl
import pprint
def main():
print "starting"
ca_cert = "./knl-backend-chain-ca.pem"
cert_file = "./backend.admin.pem"
key_file = "./backend.admin-key.pem"
ssl_context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH,
cafile=ca_cert
)
ssl_context.load_cert_chain(cert_file, key_file)
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_REQUIRED
print "certs loaded"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ssl_sock = ssl_context.wrap_socket(s)
ssl_sock.connect(('localhost', 5670))
print "success"
if __name__ == "__main__":
main() starting
certs loaded
Traceback (most recent call last):
File "client.py", line 35, in <module>
main()
File "client.py", line 25, in main
ssl_sock.connect(('localhost', 5670))
File "/usr/lib/python2.7/ssl.py", line 882, in connect
self._real_connect(addr, False)
File "/usr/lib/python2.7/ssl.py", line 869, in _real_connect
socket.connect(self, addr)
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused # openssl x509 -in server.rabbitmq.pem -text -noout
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
<omitted>
Signature Algorithm: sha256WithRSAEncryption
Issuer: <omitted>
Validity
Not Before: Jan 9 08:11:00 2020 GMT
Not After : Jan 8 08:11:00 2021 GMT
Subject: <omitted>, CN = server.rabbitmq
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
Modulus:
<omitted>
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Subject Key Identifier:
<omitted>
X509v3 Authority Key Identifier:
<omitted>
X509v3 Subject Alternative Name:
DNS:
Signature Algorithm: sha256WithRSAEncryption
<omitted> # rabbitmq-diagnostics cipher_suites --format openssl --silent
ECDHE-ECDSA-AES256-GCM-SHA384
ECDHE-RSA-AES256-GCM-SHA384
ECDHE-ECDSA-AES256-SHA384
ECDHE-RSA-AES256-SHA384
ECDH-ECDSA-AES256-GCM-SHA384
ECDH-RSA-AES256-GCM-SHA384
ECDH-ECDSA-AES256-CBC-SHA384
ECDH-RSA-AES256-CBC-SHA384
DHE-RSA-AES256-GCM-SHA384
DHE-DSS-AES256-GCM-SHA384
DHE-RSA-AES256-SHA256
DHE-DSS-AES256-CBC-SHA256
ECDHE-ECDSA-AES128-GCM-SHA256
ECDHE-RSA-AES128-GCM-SHA256
ECDHE-ECDSA-AES128-SHA256
ECDHE-RSA-AES128-SHA256
ECDH-ECDSA-AES128-GCM-SHA256
ECDH-RSA-AES128-GCM-SHA256
ECDH-ECDSA-AES128-CBC-SHA256
ECDH-RSA-AES128-CBC-SHA256
DHE-RSA-AES128-GCM-SHA256
DHE-DSS-AES128-GCM-SHA256
DHE-RSA-AES128-SHA256
DHE-DSS-AES128-CBC-SHA256
ECDHE-ECDSA-AES256-SHA
ECDHE-RSA-AES256-SHA
DHE-RSA-AES256-SHA
DHE-DSS-AES256-CBC-SHA
ECDH-ECDSA-AES256-CBC-SHA
ECDH-RSA-AES256-CBC-SHA
ECDHE-ECDSA-AES128-SHA
ECDHE-RSA-AES128-SHA
DHE-RSA-AES128-SHA
DHE-DSS-AES128-CBC-SHA
ECDH-ECDSA-AES128-CBC-SHA
ECDH-RSA-AES128-CBC-SHA # openssl ciphers
TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:RSA-PSK-AES256-GCM-SHA384:DHE-PSK-AES256-GCM-SHA384:RSA-PSK-CHACHA20-POLY1305:DHE-PSK-CHACHA20-POLY1305:ECDHE-PSK-CHACHA20-POLY1305:AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:PSK-CHACHA20-POLY1305:RSA-PSK-AES128-GCM-SHA256:DHE-PSK-AES128-GCM-SHA256:AES128-GCM-SHA256:PSK-AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:ECDHE-PSK-AES256-CBC-SHA384:ECDHE-PSK-AES256-CBC-SHA:SRP-RSA-AES-256-CBC-SHA:SRP-AES-256-CBC-SHA:RSA-PSK-AES256-CBC-SHA384:DHE-PSK-AES256-CBC-SHA384:RSA-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA:AES256-SHA:PSK-AES256-CBC-SHA384:PSK-AES256-CBC-SHA:ECDHE-PSK-AES128-CBC-SHA256:ECDHE-PSK-AES128-CBC-SHA:SRP-RSA-AES-128-CBC-SHA:SRP-AES-128-CBC-SHA:RSA-PSK-AES128-CBC-SHA256:DHE-PSK-AES128-CBC-SHA256:RSA-PSK-AES128-CBC-SHA:DHE-PSK-AES128-CBC-SHA:AES128-SHA:PSK-AES128-CBC-SHA256:PSK-AES128-CBC-SHA log.console.level = debug
log.connection.level = debug
log.upgrade.level = debug
loopback_users.guest = false
listeners.tcp.default = 5672
management.tcp.port = 15672
listeners.ssl.default = 5671
ssl_options.cacertfile = /etc/ssl/rabbitmq/ca.pem
ssl_options.certfile = /etc/ssl/rabbitmq/cert.pem
ssl_options.keyfile = /etc/ssl/rabbitmq/key.pem
ssl_options.verify = verify_none
ssl_options.fail_if_no_peer_cert = false
ssl_options.versions.1 = tlsv1.3
ssl_options.versions.2 = tlsv1.2
ssl_options.versions.3 = tlsv1.1
ssl_cert_login_from = common_name
auth_mechanisms.1 = PLAIN
auth_mechanisms.2 = AMQPLAIN
auth_mechanisms.3 = EXTERNAL
# openssl s_server -accept 5670 -cert /etc/ssl/rabbitmq/server.rabbitmq.pem -key /etc/ssl/rabbitmq/server.rabbitmq-key.pem -CAfile /etc/ssl/rabbitmq/knl-backend-chain-ca.pem
Using default temp DH parameters
ACCEPT
-----BEGIN SSL SESSION PARAMETERS-----
<omitted>
-----END SSL SESSION PARAMETERS-----
Shared ciphers:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA
Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:ECDSA+SHA1:RSA+SHA224:RSA+SHA1:DSA+SHA224:DSA+SHA1:DSA+SHA256:DSA+SHA384:DSA+SHA512
Shared Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:ECDSA+SHA1:RSA+SHA224:RSA+SHA1
Supported Elliptic Groups: X25519:P-256:X448:P-521:P-384
Shared Elliptic groups: X25519:P-256:X448:P-521:P-384
CIPHER is TLS_AES_256_GCM_SHA384
Secure Renegotiation IS supported
ERROR
shutting down SSL
CONNECTION CLOSED# openssl s_client -connect localhost:5670 -cert /etc/ssl/rabbitmq/server.rabbitmq.pem -key /etc/ssl/rabbitmq/server.rabbitmq-key.pem -CAfile /etc/ssl/rabbitmq/knl-backend-chain-ca.pem
CONNECTED(00000003)
Can't use SSL_get_servername
depth=2 <omitted>
verify return:1
depth=1 <omitted>
verify return:1
depth=0 <omitted>, CN = server.rabbitmq
verify return:1
---
Certificate chain
0 s:C = FI, L = Oulu, CN = server.rabbitmq
i:<omitted>
1 s:<omitted>
i:<omitted>
2 s:<omitted>
i:<omitted>
---
Server certificate
-----BEGIN CERTIFICATE-----
<omitted>
-----END CERTIFICATE-----
<omitted>, CN = server.rabbitmq
issuer=<omitted>
---
No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 4096 bytes and written 373 bytes
Verification: OK
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
Protocol : TLSv1.3
Cipher : TLS_AES_256_GCM_SHA384
Session-ID: AC00AB7DD48ECF7B21D39E8729F82CD3556E4CB9724B29FE5C8282782098AB86
Session-ID-ctx:
Resumption PSK: 88922F1E36AA8B90AE9F25A0D9F508D993D4999E773FAA3F6DB392DB4A05FE7464E8F4AD2F2A512A4662A592603B0D89
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 7200 (seconds)
TLS session ticket:
<omitted>
Start Time: 1578656216
Timeout : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: no
Max Early Data: 0
---
read R BLOCKHi,I'm having trouble setting up TLS connections and X.509 certificate authentication with Rabbitmq.I have set a private PKI system using CFSSL and generated few certs using it.General information:Rabbitmq version 3.8.2 (using official Docker image)Erlang version 22.2
Rabbitmq output log shows that TLS listener is active on port 5671 but it doesn't show any connection
attempts when I try to run any test scripts. Nothing gets print to log regarding the failed connection attempt.
starting
certs loaded
Traceback (most recent call last):
File "client.py", line 35, in <module>
main()
File "client.py", line 25, in main
ssl_sock.connect(('localhost', 5671))
File "/usr/lib/python2.7/ssl.py", line 864, in connect
self._real_connect(addr, False)
File "/usr/lib/python2.7/ssl.py", line 855, in _real_connect
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 828, in do_handshake
self._sslobj.do_handshake()
socket.error: [Errno 104] Connection reset by peer
# openssl s_client -connect localhost:5671 -cert /etc/ssl/rabbitmq/server.rabbitmq.pem -key /etc/ssl/rabbitmq/server.rabbitmq-key.pem -CAfile /etc/ssl/rabbitmq/knl-backend-chain-ca.pem -state -debug# openssl s_client -connect localhost:5671 -cert /etc/ssl/rabbitmq/server.rabbitmq.pem -key /etc/ssl/rabbitmq/server.rabbitmq-key.pem -CAfile /etc/ssl/rabbitmq/knl-backend-chain-ca.pem -state -debugCONNECTED(00000003)SSL_connect:before SSL initializationwrite to 0x563e189eb640 [0x563e189ff6c0] (293 bytes => 293 (0x125))0000 - 16 03 01 01 20 01 00 01-1c 03 03 8c 7f 5d 8c 2f .... ........]./0010 - cc 7a 70 cf 33 2d 8e b5-19 76 7f 09 73 26 f6 1f .zp.3-...v..s&..0020 - 97 f6 f4 15 da 1b 04 9b-d3 0c 21 20 f6 50 a1 a3 ..........! .P..0030 - f0 6f ad bd db c6 af 3c-ca 4a 75 25 69 0d 2e 7f .o.....<.Ju%i...0040 - 0d eb 63 ec 3d d9 1a ce-15 94 a3 e8 00 3e 13 02 ..c.=........>..0050 - 13 03 13 01 c0 2c c0 30-00 9f cc a9 cc a8 cc aa .....,.0........0060 - c0 2b c0 2f 00 9e c0 24-c0 28 00 6b c0 23 c0 27 .+./...$.(.k.#.'0070 - 00 67 c0 0a c0 14 00 39-c0 09 c0 13 00 33 00 9d .g.....9.....3..0080 - 00 9c 00 3d 00 3c 00 35-00 2f 00 ff 01 00 00 95 ...=.<.5./......0090 - 00 0b 00 04 03 00 01 02-00 0a 00 0c 00 0a 00 1d ................00a0 - 00 17 00 1e 00 19 00 18-00 23 00 00 00 16 00 00 .........#......00b0 - 00 17 00 00 00 0d 00 30-00 2e 04 03 05 03 06 03 .......0........00c0 - 08 07 08 08 08 09 08 0a-08 0b 08 04 08 05 08 06 ................00d0 - 04 01 05 01 06 01 03 03-02 03 03 01 02 01 03 02 ................00e0 - 02 02 04 02 05 02 06 02-00 2b 00 09 08 03 04 03 .........+......00f0 - 03 03 02 03 01 00 2d 00-02 01 01 00 33 00 26 00 ......-.....3.&.0100 - 24 00 1d 00 20 dd 84 75-7c 8f 87 c1 fd e4 c7 ee $... ..u|.......0110 - eb b1 30 dc eb fe ac c8-1e 4f f2 45 bb 27 18 27 ..0......O.E.'.'0120 - 78 2d 23 c1 6f x-#.oSSL_connect:SSLv3/TLS write client helloread from 0x563e189eb640 [0x563e189f64a3] (5 bytes => -1 (0xFFFFFFFFFFFFFFFF))SSL_connect:error in SSLv3/TLS write client hellowrite:errno=104---no peer certificate available---No client certificate CA names sent---SSL handshake has read 0 bytes and written 293 bytesVerification: OK---New, (NONE), Cipher is (NONE)Secure Renegotiation IS NOT supportedCompression: NONEExpansion: NONENo ALPN negotiatedEarly data was not sentVerify return code: 0 (ok)---read from 0x563e189eb640 [0x563e189dffb0] (8192 bytes => 0 (0x0))
# openssl s_client -connect localhost:5671 -cert ./backend.admin.pem -key ./backend.admin-key.pem -CAfile ../knl-backend-chain-ca.pem -state -debug CONNECTED(00000005)SSL_connect:before SSL initializationwrite to 0x55c13fa4bd10 [0x55c13fa5fdc0] (311 bytes => 311 (0x137))0000 - 16 03 01 01 32 01 00 01-2e 03 03 bc ae 51 da 5e ....2........Q.^0010 - 0a 05 75 9d 20 61 cd 13-eb 07 5e 4d 06 b5 d2 bf ..u. a....^M....0020 - 0c ae e3 81 c2 a4 e1 66-f0 63 f3 20 77 33 15 97 .......f.c. w3..0030 - cc 3f f6 ca 38 16 50 04-0a 7d 84 64 76 01 df bf .?..8.P..}.dv...0040 - 4e 07 f6 6a 2e 9f c0 ce-ed 07 01 d5 00 3e 13 02 N..j.........>..0050 - 13 03 13 01 c0 2c c0 30-00 9f cc a9 cc a8 cc aa .....,.0........0060 - c0 2b c0 2f 00 9e c0 24-c0 28 00 6b c0 23 c0 27 .+./...$.(.k.#.'0070 - 00 67 c0 0a c0 14 00 39-c0 09 c0 13 00 33 00 9d .g.....9.....3..0080 - 00 9c 00 3d 00 3c 00 35-00 2f 00 ff 01 00 00 a7 ...=.<.5./......0090 - 00 00 00 0e 00 0c 00 00-09 6c 6f 63 61 6c 68 6f .........localho00a0 - 73 74 00 0b 00 04 03 00-01 02 00 0a 00 0c 00 0a st..............00b0 - 00 1d 00 17 00 1e 00 19-00 18 00 23 00 00 00 16 ...........#....00c0 - 00 00 00 17 00 00 00 0d-00 30 00 2e 04 03 05 03 .........0......00d0 - 06 03 08 07 08 08 08 09-08 0a 08 0b 08 04 08 05 ................00e0 - 08 06 04 01 05 01 06 01-03 03 02 03 03 01 02 01 ................00f0 - 03 02 02 02 04 02 05 02-06 02 00 2b 00 09 08 03 ...........+....0100 - 04 03 03 03 02 03 01 00-2d 00 02 01 01 00 33 00 ........-.....3.0110 - 26 00 24 00 1d 00 20 8f-73 31 25 93 4b 0e a2 d1 &.$... .s1%.K...0120 - 52 17 2f 85 a1 e2 02 49-7f 5f 26 f6 f2 55 16 dc R./....I._&..U..0130 - 52 1f 0d 58 b1 86 63 R..X..cSSL_connect:SSLv3/TLS write client helloread from 0x55c13fa4bd10 [0x55c13fa56ba3] (5 bytes => 0 (0x0))SSL_connect:error in SSLv3/TLS write client hellowrite:errno=104---no peer certificate available---No client certificate CA names sent---SSL handshake has read 0 bytes and written 311 bytesVerification: OK---New, (NONE), Cipher is (NONE)Secure Renegotiation IS NOT supportedCompression: NONEExpansion: NONENo ALPN negotiatedEarly data was not sentVerify return code: 0 (ok)---read from 0x55c13fa4bd10 [0x55c13fa40d80] (8192 bytes => 0 (0x0))Hi,