Commit b24a9ed4 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed possible NPE.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8445 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7bfc8c62
...@@ -400,10 +400,10 @@ public class CertificateManager { ...@@ -400,10 +400,10 @@ public class CertificateManager {
List<X509Certificate> newCerts; List<X509Certificate> newCerts;
if (certs.size() == 1) { if (certs.size() == 1) {
// Reply has only one certificate // Reply has only one certificate
newCerts = establishCertChain(keyStore, trustStore, certificate, certs.get(0), trustCACerts); newCerts = establishCertChain(keyStore, trustStore, null, certs.get(0), trustCACerts);
} else { } else {
// Reply has a chain of certificates // Reply has a chain of certificates
newCerts = validateReply(keyStore, trustStore, alias, certificate, certs, trustCACerts, validateRoot); newCerts = validateReply(keyStore, trustStore, alias, null, certs, trustCACerts, validateRoot);
} }
if (newCerts != null) { if (newCerts != null) {
keyStore.setKeyEntry(alias, privKey, keyPassword.toCharArray(), keyStore.setKeyEntry(alias, privKey, keyPassword.toCharArray(),
...@@ -638,20 +638,24 @@ public class CertificateManager { ...@@ -638,20 +638,24 @@ public class CertificateManager {
throws Exception { throws Exception {
// order the certs in the reply (bottom-up). // order the certs in the reply (bottom-up).
int i; int i;
PublicKey userPubKey = userCert.getPublicKey(); X509Certificate tmpCert;
for (i = 0; i < replyCerts.size(); i++) { if (userCert != null) {
if (userPubKey.equals(replyCerts.get(i).getPublicKey())) { PublicKey userPubKey = userCert.getPublicKey();
break; for (i = 0; i < replyCerts.size(); i++) {
if (userPubKey.equals(replyCerts.get(i).getPublicKey())) {
break;
}
} }
} if (i == replyCerts.size()) {
if (i == replyCerts.size()) { throw new Exception(
throw new Exception( "Certificate reply does not contain public key for <alias>: " + alias);
"Certificate reply does not contain public key for <alias>: " + alias); }
tmpCert = replyCerts.get(0);
replyCerts.set(0, replyCerts.get(i));
replyCerts.set(i, tmpCert);
} }
X509Certificate tmpCert = replyCerts.get(0);
replyCerts.set(0, replyCerts.get(i));
replyCerts.set(i, tmpCert);
Principal issuer = replyCerts.get(0).getIssuerDN(); Principal issuer = replyCerts.get(0).getIssuerDN();
for (i = 1; i < replyCerts.size() - 1; i++) { for (i = 1; i < replyCerts.size() - 1; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment