0

I am trying to expose a RDBMS datasource as a service. And I am trying to connect to a MSSQL (SQL Server) database. But I am getting the error "Connection failed Could not connect to database" when I try to test the connection to the database.

My Configuration:


Connection Error while trying to test the connection:

Do you have any ideas why I am getting this error. Note: I have created a ms sql db server instance using docker container and I can access this through the ssms by giving the user credentials without any issues. (i.e) localhost 1433 server, Username : SA and the relevent password).

I was expecting to connect to the DB without any issue. And I was following the tutorials given in the link: https://apim.docs.wso2.com/en/latest/tutorials/integration-tutorials/sending-a-simple-message-to-a-datasource/

Error

ERROR {DBDeployer} - The data-1.0.0.dbs service, which is not valid, caused {1} DS Fault Message: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target". ClientConnectionId:1ac75219-318a-4126-930e-3fdc6a82721d DS Code: CONNECTION_UNAVAILABLE_ERRO
ycr
  • 12,828
  • 2
  • 25
  • 45
  • Just ignore this error DB config page and deploy the service. And then try to invoke the service. If you get a error when invoking, add the error trace you get to the question. – ycr Mar 20 '23 at 11:11
  • @ycr Hi. Thank you for the Reply. I did as you told but it gives the below error. ERROR {DBDeployer} - The data-1.0.0.dbs service, which is not valid, caused {1} DS Fault Message: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target". ClientConnectionId:1ac75219-318a-4126-930e-3fdc6a82721d DS Code: CONNECTION_UNAVAILABLE_ERROR – user21348790 Mar 21 '23 at 08:16

1 Answers1

0

The error indicates that you are missing the MSSQL certificate in the client's trustore. Hence try importing the MSSQL Public certificate to WSO2 trustore. Take a look at this document for more details.

keytool -import -alias <alias> -keystore  $IS_HOME/repository/resources/security/client-trustore.jks -file mssql.cer

Also you can try disabling SSL verification(not recommended) by adding the following properties to the connection URL.

encrypt=false;trustServerCertificate=false;
ycr
  • 12,828
  • 2
  • 25
  • 45