Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check tls protocol version and throw warning #1322

Merged
merged 3 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
ulvii marked this conversation as resolved.
Show resolved Hide resolved
String warningMsg = tlsProtocol
+ " was negotiated. Please update server and client to use TLSv1.2 at minimum.";
ulvii marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -3572,7 +3572,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