File tree 3 files changed +71
-570
lines changed
libs/ssl-config/src/main/java/org/opensearch/common/ssl
server/src/main/java/org/opensearch/common/settings
3 files changed +71
-570
lines changed Original file line number Diff line number Diff line change 32
32
33
33
package org .opensearch .common .ssl ;
34
34
35
+ import org .bouncycastle .pkcs .PKCSException ;
36
+
35
37
import javax .net .ssl .KeyManagerFactory ;
36
38
import javax .net .ssl .X509ExtendedKeyManager ;
37
39
@@ -82,7 +84,12 @@ public X509ExtendedKeyManager createKeyManager() {
82
84
83
85
private PrivateKey getPrivateKey () {
84
86
try {
85
- final PrivateKey privateKey = PemUtils .readPrivateKey (key , () -> keyPassword );
87
+ final PrivateKey privateKey = PemUtils .readPrivateKey (key , () -> {
88
+ if (keyPassword .length == 0 ) {
89
+ throw new SslConfigException ("cannot read encrypted key [" + key .toAbsolutePath () + "] without a password" );
90
+ }
91
+ return keyPassword ;
92
+ });
86
93
if (privateKey == null ) {
87
94
throw new SslConfigException ("could not load ssl private key file [" + key + "]" );
88
95
}
@@ -91,7 +98,7 @@ private PrivateKey getPrivateKey() {
91
98
throw new SslConfigException ("the configured ssl private key file [" + key .toAbsolutePath () + "] does not exist" , e );
92
99
} catch (IOException e ) {
93
100
throw new SslConfigException ("the configured ssl private key file [" + key .toAbsolutePath () + "] cannot be read" , e );
94
- } catch (GeneralSecurityException e ) {
101
+ } catch (PKCSException e ) {
95
102
throw new SslConfigException ("cannot load ssl private key file [" + key .toAbsolutePath () + "]" , e );
96
103
}
97
104
}
You can’t perform that action at this time.
0 commit comments