Open sando38 opened 8 months ago
+1
I am using client certificate authentication between ejabberd and postgres. I can only get a successful connection when sql_ssl_verify
is set to false
.
loglevel: debug
[...]
new_sql_schema: true
default_db: sql
sql_server: 1.2.3.4
sql_port: 5432
sql_database: ejabberd
sql_type: pgsql
# no username/password defined, postgres configured with client cert auth
sql_ssl: true
sql_ssl_verify: true
sql_ssl_cafile: "/path/to/ca.crt"
sql_ssl_certfile: "/path/to/user@certfile.pem"
ssl = on
ssl_ca_file = '/path/to/ca.crt'
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'
#TYPE DATABASE USER ADDRESS METHOD
hostssl ejabberd user 1.2.3.4/5 cert clientcert=verify-full
22:20:57.330 [notice] TLS :client: In state :wait_cert at ssl_handshake.erl:2127 generated CLIENT ALERT: Fatal - Handshake Failure
- {:bad_cert, :hostname_check_failed}
22:20:57.333 [warning] :pgsql connection failed:
** Reason: {:tls_alert,
{:handshake_failure,
~c"TLS client: In state wait_cert at ssl_handshake.erl:2127 generated CLIENT ALERT: Fatal - Handshake Failure\n {bad_cert,hostname_check_failed}"}}
** Retry after: 30 seconds
[32081] LOG: 08P01: could not accept SSL connection: sslv3 alert handshake failure
[32081] LOCATION: be_tls_open_server, be-secure-openssl.c:508
If you are using ip address to connect to sql server, there is no chance that cert domain validation will pass - there is domain used. You would need to make sql_server point to domain from cert to get pass that.
If you are using ip address to connect to sql server, there is no chance that cert domain validation will pass - there is domain used. You would need to make sql_server point to domain from cert to get pass that.
Ah, fair point. That being said, the issue persists when setting sql_server
to the fqdn as well.
It may be of note that postgres and ejabberd are both running on the same machine, I plan on testing further with them on separate hosts.
Edit:
Tested with fqdn using postgres hosted on separate host, and the issue continues to persist.
Is there a specific format ejabberd needs the certificate files to be in?
e.g. does sql_ssl_cafile
need to contain the full chain between the ca public key to the postgres server's public key?
FWIW the server certificates were issued via acme with an internal certificate authority. Additionally, connecting to postgres using client-certificate authentication succeeds both via the command line using psql
and when defined in the ejabberd configuration file.
All systems were configured to include the appropriate ca chain in the trust store accordingly, and are able to utilize other services requiring SSL under the same certificate authority.
Environment
26.2
Configuration (only if needed): grep -Ev '^$|^\s*#' ejabberd.yml
Errors from error.log/crash.log
Bug description
I cannot connect to Postgres with
sql_ssl_verify: true
. I have the above error messages. When I use a simplepsql
client using the same certificates, it works:Here is the corresponding Postgres error message:
The CA certificate is PEM encoded. Without the
sql_ssl_verify: true
option, only presenting the client certificate, it works.I am not sure if this is a problem on my side with ejabberd or Postgres. I am happy for any advice.