- Newest
- Most votes
- Most comments
SQL Server uses STARTTLS to support both unencrypted and encrypted connections on port 1433. OpenSSL s_client will not work.
While it support -starttls switch, OpenSSL does not support STARTTLS with SQL.
For SMTP mail server, the syntax is as follows
openssl s_client -starttls smtp -connect MAIL-SERVER:25
Below commands are on Amazon Linux 20223 with Microsoft ODBC driver for SQL Server (Linux) installed
You can install nmap and use it to retrieve TLS cert as illustrated below
[ec2-user@ip ~]$ nmap --script=ssl-cert -p 1433 database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com -Pn
Starting Nmap 7.93 ( https://nmap.org ) at 2025-01-19 06:01 UTC
Nmap scan report for database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com (172.31.48.4)
Host is up (0.00034s latency).
rDNS record for 172.31.48.4: ip-172-31-48-4.ap-southeast-1.compute.internal
PORT STATE SERVICE
1433/tcp open ms-sql-s
| ssl-cert: Subject: commonName=database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com/organizationName=Amazon.com/stateOrProvinceName=Washington/countryName=US
| Subject Alternative Name: DNS:database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com, DNS:listener.database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com
| Issuer: commonName=Amazon RDS ap-southeast-1 Subordinate CA RSA2048 G1.A.3/organizationName=Amazon Web Services, Inc./stateOrProvinceName=WA/countryName=US
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2025-01-19T05:48:02
| Not valid after: 2028-01-19T05:48:02
| MD5: 6f6a3308392c51c42f0315543e132964
|_SHA-1: f98fe421a544cc766f22673e1ca76e5d84dde72f
Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds
With regards to your error, you may want to create a new parameter group and attach it to your RDS SQL server
sqlcmd -S database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com -U <USER> -P <PASSWORD> -Nm
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider: [error:0A000086:SSL routines::certificate verify failed:unable to get local issuer certificate].
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722.
Reboot RDS SQL.
On your client, add CA bundle to /usr/share/pki/ca-trust-source/anchors and running sudo update-ca-trust
With force_ssl enabled...
[ec2-user@ip ~]$ sqlcmd -S database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com -U <USER> -P <PASSWORD> -Ns
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : TCP Provider: Error code 0x2746.
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection.
[ec2-user@ip ~]$ sqlcmd -S database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com -U <USER> -P <PASSWORD> -Nm
1> select ENCRYPT_OPTION from SYS.DM_EXEC_CONNECTIONS where SESSION_ID = @@SPID
2> go
ENCRYPT_OPTION
----------------------------------------
TRUE
(1 rows affected)
1> quit
[ec2-user@ip anchors]$ sqlcmd -S database-1.cxvgib1qvhwr.ap-southeast-1.rds.amazonaws.com -U <USER> -P <PASSWORD>
1> select ENCRYPT_OPTION from SYS.DM_EXEC_CONNECTIONS where SESSION_ID = @@SPID
2> GO
ENCRYPT_OPTION
----------------------------------------
TRUE
(1 rows affected)
Based on the information provided, it appears you're experiencing several issues with SSL communication to your Amazon RDS SQL Server instance. Let's address your questions and provide some insights:
-
The OpenSSL handshake failure could be due to a mismatch between the SSL/TLS versions supported by the server and the one you're trying to use. The error "unexpected eof while reading" often indicates that the server closed the connection prematurely, possibly because it doesn't support the SSL/TLS version you're attempting to use.
-
The rds.force_ssl parameter remaining in "pending-reboot" state after multiple reboots is unusual. This could indicate an issue with the parameter group application or a problem with the RDS instance itself. You may need to contact AWS support if this persists after ensuring you're modifying the correct parameter group and that it's associated with your DB instance.
Regarding SQLCMD enforcing SSL: When you use the -N and -C flags with SQLCMD, you are requesting an encrypted connection. The fact that your query on SYS.DM_EXEC_CONNECTIONS returns TRUE for ENCRYPT_OPTION suggests that the connection is indeed encrypted. However, to be absolutely certain, you can try the following:
-
Use SQL Server Management Studio (SSMS) to connect, and in the connection properties, set "Encrypt connection" to "Yes" and uncheck "Trust server certificate". If the connection succeeds, it confirms SSL is working correctly.
-
Check the SQL Server error log for entries related to SSL connections.
To ensure proper SSL enforcement:
-
Verify that the rds.force_ssl parameter is actually applied after a reboot. You can check this using the AWS CLI or RDS console.
-
Make sure you're using the correct and up-to-date SSL certificate. The rds-ca-rsa2048-g1 is a newer certificate, so ensure your client trusts this certificate.
-
Import the RDS certificate into your client's trusted root certification authorities store.
-
If using SSMS version 19.3, 20.0, or 20.2, you may need to enable "Trust Server Certificate" and import the certificate into your system.
-
Check if there are any security group or network ACL rules that might be interfering with SSL connections.
If issues persist after trying these steps, you may need to engage AWS support for further investigation, especially regarding the rds.force_ssl parameter not applying correctly.
Sources
Sql Server: Certificate Authority not trusted with new rds-ca-rsa2048-g1 certificate | AWS re:Post
Using SSL with a Microsoft SQL Server DB instance - Amazon Relational Database Service
Troubleshooting connections to your SQL Server DB instance - Amazon Relational Database Service
answered 2 years ago
Relevant content
asked 3 years ago
