Skip to content

Commit

Permalink
Polish PEM format support (Ericsson#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
masokol committed Sep 30, 2022
1 parent aff281d commit ece6605
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ SslContext getSSLContext()
}
}

protected static SslContext createSSLContext(TLSConfig tlsConfig) throws IOException,
protected static SslContext createSSLContext(final TLSConfig tlsConfig) throws IOException,
NoSuchAlgorithmException,
KeyStoreException,
CertificateException,
Expand All @@ -157,9 +157,9 @@ protected static SslContext createSSLContext(TLSConfig tlsConfig) throws IOExcep

SslContextBuilder builder = SslContextBuilder.forClient();

if (tlsConfig.getCertificate().isPresent() &&
tlsConfig.getCertificatePrivateKey().isPresent() &&
tlsConfig.getTrustCertificate().isPresent())
if (tlsConfig.getCertificate().isPresent()
&& tlsConfig.getCertificatePrivateKey().isPresent()
&& tlsConfig.getTrustCertificate().isPresent())
{
File certificateFile = new File(tlsConfig.getCertificate().get());
File certificatePrivateKeyFile = new File(tlsConfig.getCertificatePrivateKey().get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,34 +93,34 @@ public final void setTruststore_password(final String truststorePassword)
this.truststore_password = truststorePassword;
}

public Optional<String> getCertificate()
public final Optional<String> getCertificate()
{
return Optional.ofNullable(certificate);
}

public void setCertificate(String certificate)
public final void setCertificate(final String aCertificate)
{
this.certificate = certificate;
this.certificate = aCertificate;
}

public Optional<String> getCertificatePrivateKey()
public final Optional<String> getCertificatePrivateKey()
{
return Optional.ofNullable(certificate_private_key);
}

public void setCertificate_private_key(String certificate_private_key)
public final void setCertificate_private_key(final String certificatePrivateKey)
{
this.certificate_private_key = certificate_private_key;
this.certificate_private_key = certificatePrivateKey;
}

public Optional<String> getTrustCertificate()
public final Optional<String> getTrustCertificate()
{
return Optional.ofNullable(trust_certificate);
}

public void setTrust_certificate(String trust_certificate)
public final void setTrust_certificate(final String trustCertificate)
{
this.trust_certificate = trust_certificate;
this.trust_certificate = trustCertificate;
}

public final String getProtocol()
Expand Down Expand Up @@ -219,7 +219,8 @@ public final boolean equals(final Object o)
public final int hashCode()
{
int result = Objects.hash(enabled, keystore, keystore_password, truststore, truststore_password, certificate,
certificate_private_key, trust_certificate, protocol, algorithm, store_type, require_endpoint_verification);
certificate_private_key, trust_certificate, protocol, algorithm, store_type,
require_endpoint_verification);
result = HASH_SEED * result + Arrays.hashCode(cipher_suites);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void testSuccessfulResponseWhenValidCertificate() throws IOException, Gen
public void testExceptionWhenExpiredCertificate() throws IOException, GeneralSecurityException
{
HttpClient httpClient = configureHttpClient(CLIENT_EXPIRED_PATH);
assertThatExceptionOfType(SSLException.class)
assertThatExceptionOfType(IOException.class)
.isThrownBy(() -> httpClient.execute(new HttpGet(httpsUrl)));
}

Expand Down

0 comments on commit ece6605

Please sign in to comment.