ARTIFACTORY: How to resolve “Initiating database connection: TLS Handshake failed: x509: certificate is not valid for any names, but wanted to match…” error in Metadata service logs when connecting to MSSQL database
Affected Versions: Artifactory 7.x
Description
When setting up Artifactory to use MSSQL as the database, you may need to define a Metadata specific connection string in the system.yaml file. For more information, please refer to this KB article: Metadata Service – MSSQL Dynamic Ports Configuration
However, you may run into the following connection error message in the Metadata logs (metadata-service.log),
[RETRY] Initiating database connection: TLS Handshake failed: x509: certificate is not valid for any names, but wanted to match <DB_HOST>. Retrying in 1s ... (1/120) [database]
ResolutionTo resolve this error, you can add the “trustServerCertificate=true” flag to the connection string in the system.yaml file (located under $JFROG_HOME/artifactory/var/etc)
metadata:
database:
type: mssql
url: "go:sqlserver://<USER>:<PASSWORD>@<DB_HOST>:1433?database=<DB_NAME>&trustServerCertificate=true"
After making the change in the system.yaml file, restart Artifactory and it should resolve the issue.