Skip to content

Commit

Permalink
Check tls protocol version and throw warning (#1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-ye authored Apr 30, 2020
1 parent 088b738 commit 639d22c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,16 @@ else if (con.getTrustManagerClass() != null) {
// SSL is now enabled; switch over the channel socket
channelSocket = sslSocket;

// Check the TLS version
String tlsProtocol = sslSocket.getSession().getProtocol();
if (SSLProtocol.TLS_V10.toString().equalsIgnoreCase(tlsProtocol)
|| SSLProtocol.TLS_V11.toString().equalsIgnoreCase(tlsProtocol)) {
String warningMsg = tlsProtocol
+ " was negotiated. Please update server and client to use TLSv1.2 at minimum.";
logger.warning(warningMsg);
con.addWarning(warningMsg);
}

if (logger.isLoggable(Level.FINER))
logger.finer(toString() + " SSL enabled");
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,7 @@ public SQLWarning getWarnings() throws SQLServerException {
}

// Any changes to SQLWarnings should be synchronized.
private void addWarning(String warningString) {
void addWarning(String warningString) {
synchronized (warningSynchronization) {
SQLWarning warning = new SQLWarning(warningString);

Expand Down

0 comments on commit 639d22c

Please sign in to comment.