Skip to content

Commit b6b72da

Browse files
nfullerandi34
authored andcommitted
SCSV support
This adds the TLS fallback SCSV token. Bug: 17750026 (cherry-picked from commit e256f2c51cf406843a7ed0364399f79a63a085f6) Change-Id: I9ca3e12a8a430e647bd5421fb6fee32dba360a8c
1 parent 49d9ce3 commit b6b72da

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

android/main/java/com/squareup/okhttp/internal/Platform.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ public void enableTlsExtensions(SSLSocket socket, String uriHost) {
7272
}
7373

7474
public void supportTlsIntolerantServer(SSLSocket socket) {
75+
// In accordance with https://tools.ietf.org/html/draft-ietf-tls-downgrade-scsv-00
76+
// the SCSV cipher is added to signal that a protocol fallback has taken place.
77+
final String fallbackScsv = "TLS_FALLBACK_SCSV";
78+
boolean socketSupportsFallbackScsv = false;
79+
String[] supportedCipherSuites = socket.getSupportedCipherSuites();
80+
for (int i = supportedCipherSuites.length - 1; i >= 0; i--) {
81+
String supportedCipherSuite = supportedCipherSuites[i];
82+
if (fallbackScsv.equals(supportedCipherSuite)) {
83+
socketSupportsFallbackScsv = true;
84+
break;
85+
}
86+
}
87+
if (socketSupportsFallbackScsv) {
88+
// Add the SCSV cipher to the set of enabled ciphers.
89+
String[] enabledCipherSuites = socket.getEnabledCipherSuites();
90+
String[] newEnabledCipherSuites = new String[enabledCipherSuites.length + 1];
91+
System.arraycopy(enabledCipherSuites, 0,
92+
newEnabledCipherSuites, 0, enabledCipherSuites.length);
93+
newEnabledCipherSuites[newEnabledCipherSuites.length - 1] = fallbackScsv;
94+
socket.setEnabledCipherSuites(newEnabledCipherSuites);
95+
}
7596
socket.setEnabledProtocols(new String[]{"SSLv3"});
7697
}
7798

0 commit comments

Comments
 (0)