mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Do not abort if we could not get a KeyManagerFactory
using the default algorithm. Instead continue with 'null' as value of the KeyManager[] array (kms). This makes the SSLContext.init() methods to search the default security providers for implementations, which is also OK. This change is needed because it appears that on Android KeyManagerFactory.getDefaultAlgorithm returns 'SunX509', which subsequently results in W/AbstractXMPPConnection: Connection XMPPTCPConnection[not-authenticated] (0) closed with error java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:190) at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:139) at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:77) at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:747) at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1200(XMPPTCPConnection.java:149) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1053) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:980) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:996) at java.lang.Thread.run(Thread.java:818) Note that this is possibly because the Secuurity Provider was not (yet) intialized.
This commit is contained in:
parent
573358b459
commit
d804d4ed6d
1 changed files with 20 additions and 11 deletions
|
@ -749,19 +749,28 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
|
|
||||||
if (ks != null) {
|
if (ks != null) {
|
||||||
String keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
|
String keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
|
||||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
|
KeyManagerFactory kmf = null;
|
||||||
try {
|
try {
|
||||||
if (pcb == null) {
|
kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
|
||||||
kmf.init(ks, null);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
kmf.init(ks, pcb.getPassword());
|
|
||||||
pcb.clearPassword();
|
|
||||||
}
|
|
||||||
kms = kmf.getKeyManagers();
|
|
||||||
}
|
}
|
||||||
catch (NullPointerException npe) {
|
catch (NoSuchAlgorithmException e) {
|
||||||
LOGGER.log(Level.WARNING, "NullPointerException", npe);
|
LOGGER.log(Level.FINE, "Could get the default KeyManagerFactory for the '"
|
||||||
|
+ keyManagerFactoryAlgorithm + "' algorithm", e);
|
||||||
|
}
|
||||||
|
if (kmf != null) {
|
||||||
|
try {
|
||||||
|
if (pcb == null) {
|
||||||
|
kmf.init(ks, null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
kmf.init(ks, pcb.getPassword());
|
||||||
|
pcb.clearPassword();
|
||||||
|
}
|
||||||
|
kms = kmf.getKeyManagers();
|
||||||
|
}
|
||||||
|
catch (NullPointerException npe) {
|
||||||
|
LOGGER.log(Level.WARNING, "NullPointerException", npe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue