I have a problem with my implementation with spongycastle using tls with psk.
I get a psk from a webservice and try to connect to the webserver. In my HttpTransportLayer
class I create a socket with the server address and the port. Then i create an TLSIdentity
which gets the sessionIdentifier
and the shared key.
try {
socket = new Socket(hostAddress, port);
}catch(UnknownHostException e){
e.printStackTrace();
}
TlsPSKIdentity identity = new BcTlsPSKIdentity(sessionID.getBytes("UTF-8"), Util.hexStringToByteArray(psk));
BcPSKTlsClient pskTlsClient = new BcPSKTlsClient(identity);
this.tlsClientProtocol = new TlsClientProtocol(socket.getInputStream(), socket.getOutputStream());
this.tlsClientProtocol.connect(pskTlsClient);
outputStream = tlsClientProtocol.getOutputStream();
I am getting an exception when i try to connect with server. Does anyone know how to solve this? Thank you very much!
07-04 09:17:38.726: W/System.err(3889): java.io.IOException: Internal TLS error, this could be an attack
07-04 09:17:38.726: W/System.err(3889): at org.spongycastle.crypto.tls.TlsProtocol.failWithError(TlsProtocol.java:637)
07-04 09:17:38.736: W/System.err(3889): at org.spongycastle.crypto.tls.TlsProtocol.safeReadRecord(TlsProtocol.java:457)
07-04 09:17:38.736: W/System.err(3889): at org.spongycastle.crypto.tls.TlsProtocol.completeHandshake(TlsProtocol.java:148)
07-04 09:17:38.746: W/System.err(3889): at org.spongycastle.crypto.tls.TlsClientProtocol.connect(TlsClientProtocol.java:97)
07-04 09:17:38.756: W/System.err(3889): at de.rs.webserviceprovider.HttpTransportLayer.connect(HttpTransportLayer.java:135)
07-04 09:17:38.756: W/System.err(3889): at de.rs.webserviceprovider.HttpTransportLayer.<init>(HttpTransportLayer.java:77)
07-04 09:17:38.766: W/System.err(3889): at de.rs.eidserviceprovider.ServiceProvider.setServerConnection(ServiceProvider.java:106)
07-04 09:17:38.776: W/System.err(3889): at de.rs.eidservices.tools.AsyncConnectionTask.doInBackground(AsyncConnectionTask.java:47)
07-04 09:17:38.776: W/System.err(3889): at de.rs.eidservices.tools.AsyncConnectionTask.doInBackground(AsyncConnectionTask.java:1)
07-04 09:17:38.796: W/System.err(3889): at android.os.AsyncTask$2.call(AsyncTask.java)
07-04 09:17:38.796: W/System.err(3889): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-04 09:17:38.806: W/System.err(3889): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java)
07-04 09:17:38.816: W/System.err(3889): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-04 09:17:38.826: W/System.err(3889): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
07-04 09:17:38.826: W/System.err(3889): at java.lang.Thread.run(Thread.java:864)