1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +01:00

Fixed a problem where not fully setting up PKI results in

failed logins.


git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@9543 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Jay Kline 2007-11-30 22:11:04 +00:00 committed by jay
parent 1b5203d24e
commit e51e9432f2

View file

@ -1303,7 +1303,7 @@ public class XMPPConnection {
*/ */
void proceedTLSReceived() throws Exception { void proceedTLSReceived() throws Exception {
SSLContext context = SSLContext.getInstance("TLS"); SSLContext context = SSLContext.getInstance("TLS");
KeyStore ks; KeyStore ks = null;
KeyManager[] kms = null; KeyManager[] kms = null;
PasswordCallback pcb = null; PasswordCallback pcb = null;
@ -1311,7 +1311,11 @@ public class XMPPConnection {
ks = null; ks = null;
} else { } else {
System.out.println("Keystore type: "+configuration.getKeystoreType()); System.out.println("Keystore type: "+configuration.getKeystoreType());
if(configuration.getKeystoreType().equals("PKCS11")) { if(configuration.getKeystoreType().equals("NONE")) {
ks = null;
pcb = null;
}
else if(configuration.getKeystoreType().equals("PKCS11")) {
Provider p = new sun.security.pkcs11.SunPKCS11(configuration.getPKCSConfig()); Provider p = new sun.security.pkcs11.SunPKCS11(configuration.getPKCSConfig());
Security.addProvider(p); Security.addProvider(p);
ks = KeyStore.getInstance("PKCS11",p); ks = KeyStore.getInstance("PKCS11",p);
@ -1327,9 +1331,15 @@ public class XMPPConnection {
} }
else { else {
ks = KeyStore.getInstance(configuration.getKeystoreType()); ks = KeyStore.getInstance(configuration.getKeystoreType());
pcb = new PasswordCallback("Keystore Password: ",false); try {
callbackHandler.handle(new Callback[]{pcb}); ks.load(new FileInputStream(configuration.getKeystorePath()), pcb.getPassword());
ks.load(new FileInputStream(configuration.getKeystorePath()), pcb.getPassword()); pcb = new PasswordCallback("Keystore Password: ",false);
callbackHandler.handle(new Callback[]{pcb});
}
catch(Exception e) {
ks = null;
pcb = null;
}
} }
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
try { try {