Schau bitte nochmal drüber. Selbe Fehlermeldung noch.
Code
ublic void onClick(final View v) {
if (IP.getText().toString().equals(null) || Port.getText().toString().equals(null)){
Toast.makeText(getApplicationContext(), "Bitte IP und Port eingeben", Toast.LENGTH_LONG).show();
}else {
final String temp = Message.getText().toString();
if (temp == null){
}
port = Integer.parseInt(Port.getText().toString());
ip_address = IP.getText().toString();
try{
//HIER DEN NETZWERK-OPERATIONEN IN NEUEN THREAD STARTEN
new Thread() {
@Override
public void run() {
try {
KeyStore ks = KeyStore.getInstance("BKS");
InputStream keyin = getApplicationContext().getResources().openRawResource(R.raw.neuserverkeypem);
ks.load(keyin,keystorepass);
org.apache.http.conn.ssl.SSLSocketFactory socketFactory = new org.apache.http.conn.ssl.SSLSocketFactory(ks);
socketFactory.setHostnameVerifier(socketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
socket = (SSLSocket)
socketFactory.createSocket(new Socket(ip_address,port), ip_address, port, false);
socket.startHandshake();
printServerCertificate(socket);
printSocketInfo(socket);
out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
chat(temp);
} catch (UnknownHostException e) {
Toast.makeText(getApplicationContext(), "Unknown host", Toast.LENGTH_SHORT).show();
Log.i(TAG,"Unknown host");
//System.exit(1);
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "No I/O", Toast.LENGTH_SHORT).show();
Log.i(TAG,"No I/O");
e.printStackTrace();
//System.exit(1);
} catch (KeyStoreException e) {
Toast.makeText(getApplicationContext(), "Keystore ks error", Toast.LENGTH_SHORT).show();
Log.i(TAG,"Keystore ks error");
//System.exit(-1);
} catch (NoSuchAlgorithmException e) {
Toast.makeText(getApplicationContext(), "No such algorithm for ks.load", Toast.LENGTH_SHORT).show();
Log.i(TAG,"No such algorithm for ks.load");
e.printStackTrace();
//System.exit(-1);
} catch (CertificateException e) {
Toast.makeText(getApplicationContext(), "certificate missing", Toast.LENGTH_SHORT).show();
Log.i(TAG,"certificate missing");
e.printStackTrace();
//System.exit(-1);
} catch (UnrecoverableKeyException e) {
Toast.makeText(getApplicationContext(), "UnrecoverableKeyException", Toast.LENGTH_SHORT).show();
Log.i(TAG,"unrecoverableKeyException");
e.printStackTrace();
//System.exit(-1);
} catch (KeyManagementException e) {
Toast.makeText(getApplicationContext(), "KeyManagementException", Toast.LENGTH_SHORT).show();
Log.i(TAG,"key management exception");
e.printStackTrace();
//System.exit(-1);
}
}
}.start();
}
catch(Exception ex){}
}
}
Alles anzeigen