TLS: Bad handshake and Unexpected EOF
I think I've setup all correctly but TLS doesn't work. I can register through 8008 but 8448 gives me the following error:
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml https://localhost:8448
New user localpart [username]: bla
Password:
Confirm password:
Make admin [no]: no
Traceback (most recent call last):
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 456, in wrap_socket
cnx.do_handshake()
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1640, in _raise_ssl_error
raise SysCallError(-1, "Unexpected EOF")
OpenSSL.SSL.SysCallError: (-1, 'Unexpected EOF')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connection.py", line 344, in connect
ssl_context=context)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 345, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 462, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='localhost', port=8448): Max retries exceeded with url: /_matrix/client/r0/admin/register (Caused by SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')",),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/register_new_matrix_user", line 22, in <module>
main()
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/_scripts/register_new_matrix_user.py", line 224, in main
admin, args.user_type)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/_scripts/register_new_matrix_user.py", line 138, in register_new_user
bool(admin), user_type)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/_scripts/register_new_matrix_user.py", line 47, in request_registration
r = requests.get(url, verify=False)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='localhost', port=8448): Max retries exceeded with url: /_matrix/client/r0/admin/register (Caused by SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')",),))
My NGINX config located at /sites-enabled/mydomain.tld
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name matrix.mydomain.tld;
location /_matrix {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
}
ssl_certificate /etc/matrix-synapse/fullchain.pem;
ssl_certificate_key /etc/matrix-synapse/privkey.pem;
}
server {
listen 8448 ssl default_server;
listen [::]:8448 ssl default_server;
server_name mydomain.tld;
location / {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
My modifications inside the original homeserver.yaml
tls_certificate_path: "/etc/matrix-synapse/fullchain.pem"
tls_private_key_path: "/etc/matrix-synapse/privkey.pem"
enable_registration: true
registration_shared_secret: "bla"
you don't seem to have configured an ssl cert for port 8448
What every I tried on Ubuntu and now on CentOS I am not able to get that beast to listen on port 8448. Netstat never shows 8448. Do you have any idea what I am doing wrong? On 8008 it works. I tried several settings in homeserver.yaml.
Who ever can show me an up to date homeserver.yaml with TLS (Let's encrypt), let me know.
I am closing this as it's not about the topic anymore. I have to figure out first, why it isn't listening on port 8448.