I'm trying to send +16kb data through multipart/formdata
. SSL implementation is
/*
* SSL Context
*/
SSLContext getSSLContext(Path keyStorePath, char[] keyStorePass) {
try {
var keyStore = KeyStore.getInstance("JKS");
keyStore.load(new FileInputStream(keyStorePath.toFile()), keyStorePass);
var keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
keyManagerFactory.init(keyStore, keyStorePass);
var sslContext = SSLContext.getInstance("SSLv3");
sslContext.init(keyManagerFactory.getKeyManagers(), null, null);
return sslContext;
}catch(Exception e) {
log.e(e,Server.class.getName(),"getSSLContext");
return null;
}
}
/*
* SSL Server Socket
*/
ServerSocket getServerSocket(InetSocketAddress address) {
try {
int backlog = MaxConcurrentRequests * 10;
var keyStorePath = Path.of("./keystore.jks");
char[] keyStorePassword = "ZZZZZZ".toCharArray();
var serverSocket = getSSLContext(keyStorePath, keyStorePassword)
.getServerSocketFactory()
.createServerSocket(address.getPort(), backlog, address.getAddress());
Arrays.fill(keyStorePassword, '0');
return serverSocket;
}catch(Exception e) {
log.e(e,Server.class.getName(),"getServerSocket");
return null;
}
}
It doesn't read any data beyond 16384 bytes, I use `DataInputStream` and `DataOutputStream`.
Also, TLS Maximum record size is 16kb (I already know that).
Is there any workaround for this limitation?
Also, How does TLS/SSL behave when there's a +16kb of `multipart/form-data` is being sent to server, does the protocol make buffers 16kb each?
Read Function, s.available() always return 16384 if the file is larger than 16384 bytes.
/*
* Reads from socket into ArrayList
*/
public static ArrayList<Byte> read(DataInputStream s,int MAX_REQ_SIZE) {
ArrayList<Byte> result = new ArrayList<Byte>();
int byteCounter = 0;
try {
do {
if(byteCounter < MAX_REQ_SIZE*1000) {
result.add(s.readByte());
if(byteCounter == 0) log.s(s.available()+"");
byteCounter ++;
}else {
}
} while (s.available() > 0);
log.i(result.size()+" bytes as request");
} catch (IOException e) {
log.e(e,Network.class.getName(),"read");
}
return result;
}
NOTE: I ran wireshark, it sends buffers of ~16000 bytes with ACK packets between, Is there any read function that can handle this?