i try to setup one SSL Server Socket in my Android project, i refer many talks in stackoverflow and finally i initialize my Server Socket like following code
//=================================
String type = KeyStore.getDefaultType();
KeyStore store=KeyStore.getInstance(type);
inputStream=this.getClass().getResourceAsStream("test.bks");
store.load(inputStream, password);
inputStream.close();
String keyalg=KeyManagerFactory.getDefaultAlgorithm();
KeyManagerFactory factory=KeyManagerFactory.getInstance(keyalg);
factory.init(store,password);
KeyManager []keyManagers=factory.getKeyManagers();
context=SSLContext.getInstance("SSL");
context.init(keyManagers, null, null);
ServerSocketFactory factory= context.getServerSocketFactory();
serverSocket=(SSLServerSocket)factory.createServerSocket(12345);
while (true) {
Socket socket = serverSocket.accept();
new ReceiveSocket(socket).start();
}
//================================================
When the code step to serverSocket.accept(), it throws one exception : "javax.net.ssl.SSLException: Could not find any key store entries to support the enabled cipher suites." i try to debug one step by step and i found keyManagers seemed key issue. One of fields in Keymanagers named EntrySet is null while the similar pure Java code this EntrySet with one address. BTW the pure Java code is work correctly. I try to config the keymanager in different ways, but no happy ending:(
Could someone give me some suggestions? Thanks a lot.
Some more information
1> the android min version is 8, the target is 19
2> this code is part of library in my whole big project
3> the cerification should be OK, since i have another code to send SSL message using the same one. It works well.
Any missing, please tell me. Thanks again.
0 comments:
Post a Comment