Restore support for a write timeout.
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 326
- Avg merge
- 16h 22m
- Merged PRs (30d)
- 17
Description
In older versions I was able to hack in support for a write timeout with conscrypt. This was nice as it worked around java's inability to set a write timeout on connections. Unfortunately conscrypt no longer seems to be happy for me to set a write timeout which is disappointing as I don't think any other way exists to stop a write which is not progressing. Worse still if the write is blocked interrupting the thread doesn't kill the connection this can lead to situations in which the JVM needs to be terminated.
For reference I was setting up the socket factory with:
```
OpenSSLProvider openSSLProvider = new OpenSSLProvider();
SSLContext sc;
try {
sc = SSLContext.getInstance("TLSv1.2", openSSLProvider);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
try {
sc.init(this.keyManager, this.trustManager, new java.security.SecureRandom());
} catch (KeyManagementException e) {
throw new RuntimeException(e);
}
this.setSSLSocketFactory(new DelegatingSSLSocketFactory(sc.getSocketFactory()) {
@Override
protected SSLSocket configureSocket(SSLSocket sslSocket) throws IOException {
if(sslSocket instanceof OpenSSLSocketImpl) {
OpenSSLSocketImpl conscryptSocket = (OpenSSLSocketImpl) sslSocket;
// The timeout is being set here.
conscryptSocket.setSoWriteTimeout(writeTimeoutMs);
}
return super.configureSocket(sslSocket);
}
});
```
Contributor guide
Assessment
This issue has not been assessed yet.