Skip to content

Commit bb7b05b

Browse files
authored
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>
1 parent 2bcd03f commit bb7b05b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

handler/src/main/java/io/netty/handler/ssl/OpenSslX509KeyManagerFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.netty.handler.ssl;
1717

1818
import static io.netty.util.internal.ObjectUtil.checkNonEmpty;
19+
import static io.netty.util.internal.ObjectUtil.checkNotNull;
1920

2021
import io.netty.buffer.ByteBufAllocator;
2122
import io.netty.buffer.UnpooledByteBufAllocator;
@@ -254,6 +255,7 @@ public static OpenSslX509KeyManagerFactory newEngineBased(File certificateChain,
254255
public static OpenSslX509KeyManagerFactory newEngineBased(X509Certificate[] certificateChain, String password)
255256
throws CertificateException, IOException,
256257
KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
258+
checkNotNull(certificateChain, "certificateChain");
257259
KeyStore store = new OpenSslKeyStore(certificateChain.clone(), false);
258260
store.load(null, null);
259261
OpenSslX509KeyManagerFactory factory = new OpenSslX509KeyManagerFactory();
@@ -286,6 +288,7 @@ public static OpenSslX509KeyManagerFactory newKeyless(InputStream chain)
286288
public static OpenSslX509KeyManagerFactory newKeyless(X509Certificate... certificateChain)
287289
throws CertificateException, IOException,
288290
KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
291+
checkNotNull(certificateChain, "certificateChain");
289292
KeyStore store = new OpenSslKeyStore(certificateChain.clone(), true);
290293
store.load(null, null);
291294
OpenSslX509KeyManagerFactory factory = new OpenSslX509KeyManagerFactory();

0 commit comments

Comments
 (0)