Issue #901 - Overriding SSL context KeyStoreType requires explicit override of TrustStoreType.

Improved code that defaults trustStore parameters from the keyStore parameters.
This commit is contained in:
Simone Bordet 2017-10-10 21:20:18 +02:00
parent d34f04c559
commit a8d08df84f
1 changed files with 6 additions and 14 deletions

View File

@ -665,12 +665,12 @@ public class SslContextFactory extends AbstractLifeCycle implements Dumpable
} }
/** /**
* @return The type of the trust store (defaults to type of the key store if unspecified) * @return The type of the trust store
*/ */
@ManagedAttribute("The trustStore type") @ManagedAttribute("The trustStore type")
public String getTrustStoreType() public String getTrustStoreType()
{ {
return _trustStoreType != null ? _trustStoreType : _keyStoreType; return _trustStoreType;
} }
/** /**
@ -1077,19 +1077,11 @@ public class SslContextFactory extends AbstractLifeCycle implements Dumpable
*/ */
protected KeyStore loadTrustStore(Resource resource) throws Exception protected KeyStore loadTrustStore(Resource resource) throws Exception
{ {
String type = getTrustStoreType(); String type = Objects.toString(getTrustStoreType(), getKeyStoreType());
String provider = getTrustStoreProvider(); String provider = Objects.toString(getTrustStoreProvider(), getKeyStoreProvider());
String passwd = Objects.toString(_trustStorePassword, null); String passwd = Objects.toString(_trustStorePassword, Objects.toString(_keyStorePassword, null));
if (resource == null || resource.equals(_keyStoreResource)) if (resource == null)
{
resource = _keyStoreResource; resource = _keyStoreResource;
if (type == null)
type = _keyStoreType;
if (provider == null)
provider = _keyStoreProvider;
if (passwd == null)
passwd = Objects.toString(_keyStorePassword, null);
}
return CertificateUtils.getKeyStore(resource, type, provider, passwd); return CertificateUtils.getKeyStore(resource, type, provider, passwd);
} }