KeyManager and TrustManager throw exceptions if used when uninitialized
parent
2353670bd8
commit
90627f0864
|
@ -42,6 +42,7 @@ import javax.net.ssl.ManagerFactoryParameters;
|
|||
public class WolfSSLKeyManager extends KeyManagerFactorySpi {
|
||||
private char[] pswd;
|
||||
private KeyStore store;
|
||||
private boolean initialized = false;
|
||||
|
||||
/** Default WolfSSLKeyManager constructor */
|
||||
public WolfSSLKeyManager() { }
|
||||
|
@ -136,6 +137,7 @@ public class WolfSSLKeyManager extends KeyManagerFactorySpi {
|
|||
}
|
||||
}
|
||||
this.store = certs;
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,11 +153,17 @@ public class WolfSSLKeyManager extends KeyManagerFactorySpi {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected KeyManager[] engineGetKeyManagers() {
|
||||
protected KeyManager[] engineGetKeyManagers()
|
||||
throws IllegalStateException {
|
||||
|
||||
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||
"entered engineGetKeyManagers()");
|
||||
|
||||
if (!this.initialized) {
|
||||
throw new IllegalStateException("KeyManagerFactory must be " +
|
||||
"initialized before use, please call init()");
|
||||
}
|
||||
|
||||
KeyManager[] km = {new WolfSSLKeyX509(this.store, this.pswd)};
|
||||
return km;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import com.wolfssl.WolfSSLJNIException;
|
|||
*/
|
||||
public class WolfSSLTrustManager extends TrustManagerFactorySpi {
|
||||
private KeyStore store;
|
||||
private boolean initialized = false;
|
||||
|
||||
/** Default WolfSSLTrustManager constructor */
|
||||
public WolfSSLTrustManager() { }
|
||||
|
@ -352,6 +353,7 @@ public class WolfSSLTrustManager extends TrustManagerFactorySpi {
|
|||
}
|
||||
}
|
||||
this.store = certs;
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -367,11 +369,18 @@ public class WolfSSLTrustManager extends TrustManagerFactorySpi {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected TrustManager[] engineGetTrustManagers() {
|
||||
protected TrustManager[] engineGetTrustManagers()
|
||||
throws IllegalStateException {
|
||||
|
||||
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||
"entered engineGetTrustManagers()");
|
||||
|
||||
if (!this.initialized) {
|
||||
throw new IllegalStateException("TrustManagerFactory must be " +
|
||||
"initialized before use, please call init()");
|
||||
}
|
||||
|
||||
|
||||
/* array of WolfSSLX509Trust objects to use */
|
||||
TrustManager[] tm = {new WolfSSLTrustX509(this.store)};
|
||||
return tm;
|
||||
|
|
Loading…
Reference in New Issue