Add explicit null checks in OpenSslX509KeyManagerFactory (#11230)
Motivation: We should add explicit null checks so its easier for people to understand why it throws. Modification: Add explicit checkNotNull(...) Result: Easier to understand for users why it fails. Signed-off-by: xingrufei <xingrufei@sogou-inc.com> Co-authored-by: xingrufei <xingrufei@sogou-inc.com>
This commit is contained in:
parent
fe5a56fc01
commit
e10c1af314
@ -17,6 +17,7 @@ package io.netty.handler.ssl;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNonEmpty;
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
@ -254,6 +255,7 @@ public final class OpenSslX509KeyManagerFactory extends KeyManagerFactory {
|
||||
public static OpenSslX509KeyManagerFactory newEngineBased(X509Certificate[] certificateChain, String password)
|
||||
throws CertificateException, IOException,
|
||||
KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
|
||||
checkNotNull(certificateChain, "certificateChain");
|
||||
KeyStore store = new OpenSslKeyStore(certificateChain.clone(), false);
|
||||
store.load(null, null);
|
||||
OpenSslX509KeyManagerFactory factory = new OpenSslX509KeyManagerFactory();
|
||||
@ -286,6 +288,7 @@ public final class OpenSslX509KeyManagerFactory extends KeyManagerFactory {
|
||||
public static OpenSslX509KeyManagerFactory newKeyless(X509Certificate... certificateChain)
|
||||
throws CertificateException, IOException,
|
||||
KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
|
||||
checkNotNull(certificateChain, "certificateChain");
|
||||
KeyStore store = new OpenSslKeyStore(certificateChain.clone(), true);
|
||||
store.load(null, null);
|
||||
OpenSslX509KeyManagerFactory factory = new OpenSslX509KeyManagerFactory();
|
||||
|
Loading…
Reference in New Issue
Block a user