com.crabshue.commons.http.client.ssl.SslOptions Maven / Gradle / Ivy
package com.crabshue.commons.http.client.ssl;
import com.crabshue.commons.exceptions.SystemException;
import com.crabshue.commons.exceptions.context.CommonErrorContext;
import com.crabshue.commons.http.client.exceptions.HttpClientErrorType;
import lombok.Data;
import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
@Data
public final class SslOptions {
public static SslOptions defaultSslOptions() {
return new SslOptions();
}
private SSLContext sslContext;
public SslOptions() {
try {
this.sslContext = SSLContext.getInstance("SSL");
this.sslContext.init(null, null, new SecureRandom());
} catch (NoSuchAlgorithmException e) {
throw new SystemException(HttpClientErrorType.SSL_CONTEXT_UNKNOWN_INSTANCE, e)
.addContextValue(CommonErrorContext.CAUSE, "SSL");
} catch (KeyManagementException e) {
throw new SystemException(HttpClientErrorType.CANNOT_INITIALIZE_SSL_CONTEXT, e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy