use of org.apache.logging.log4j.core.net.ssl.SslConfiguration in project logging-log4j2 by apache.
the class ConfigurationSource method getConfigurationSource.
private static ConfigurationSource getConfigurationSource(final URL url) {
try {
final URLConnection urlConnection = url.openConnection();
final AuthorizationProvider provider = ConfigurationFactory.authorizationProvider(PropertiesUtil.getProperties());
provider.addAuthorization(urlConnection);
if (url.getProtocol().equals(HTTPS)) {
final SslConfiguration sslConfiguration = SslConfigurationFactory.getSslConfiguration();
if (sslConfiguration != null) {
((HttpsURLConnection) urlConnection).setSSLSocketFactory(sslConfiguration.getSslSocketFactory());
if (!sslConfiguration.isVerifyHostName()) {
((HttpsURLConnection) urlConnection).setHostnameVerifier(LaxHostnameVerifier.INSTANCE);
}
}
}
final File file = FileUtils.fileFromUri(url.toURI());
try {
if (file != null) {
return new ConfigurationSource(urlConnection.getInputStream(), FileUtils.fileFromUri(url.toURI()));
} else {
return new ConfigurationSource(urlConnection.getInputStream(), url, urlConnection.getLastModified());
}
} catch (final FileNotFoundException ex) {
ConfigurationFactory.LOGGER.info("Unable to locate file {}, ignoring.", url.toString());
return null;
}
} catch (final IOException | URISyntaxException ex) {
ConfigurationFactory.LOGGER.warn("Error accessing {} due to {}, ignoring.", url.toString(), ex.getMessage());
return null;
}
}
use of org.apache.logging.log4j.core.net.ssl.SslConfiguration in project logging-log4j2 by apache.
the class Log4j2CloudConfigLoggingSystem method getConfigurationSource.
private ConfigurationSource getConfigurationSource(URL url) throws IOException, URISyntaxException {
URLConnection urlConnection = url.openConnection();
AuthorizationProvider provider = ConfigurationFactory.authorizationProvider(PropertiesUtil.getProperties());
provider.addAuthorization(urlConnection);
if (url.getProtocol().equals(HTTPS)) {
SslConfiguration sslConfiguration = SslConfigurationFactory.getSslConfiguration();
if (sslConfiguration != null) {
((HttpsURLConnection) urlConnection).setSSLSocketFactory(sslConfiguration.getSslSocketFactory());
if (!sslConfiguration.isVerifyHostName()) {
((HttpsURLConnection) urlConnection).setHostnameVerifier(LaxHostnameVerifier.INSTANCE);
}
}
}
File file = FileUtils.fileFromUri(url.toURI());
try {
if (file != null) {
return new ConfigurationSource(urlConnection.getInputStream(), FileUtils.fileFromUri(url.toURI()));
} else {
return new ConfigurationSource(urlConnection.getInputStream(), url, urlConnection.getLastModified());
}
} catch (FileNotFoundException ex) {
LOGGER.info("Unable to locate file {}, ignoring.", url.toString());
return null;
}
}
use of org.apache.logging.log4j.core.net.ssl.SslConfiguration in project logging-log4j2 by apache.
the class TlsSyslogAppenderTest method createAppender.
private SyslogAppender createAppender() {
String format;
if (messageFormat == TlsSyslogMessageFormat.LEGACY_BSD) {
format = "LEGACY_BSD";
} else {
format = "RFC5424";
}
final SslConfiguration sslConfiguration1 = sslConfiguration;
final boolean newLine = includeNewLine;
final String format1 = format;
// @formatter:off
return SyslogAppender.newSyslogAppenderBuilder().setHost("localhost").setPort(PORTNUM).setProtocol(EnglishEnums.valueOf(Protocol.class, "SSL")).setSslConfiguration(sslConfiguration1).setConnectTimeoutMillis(0).setReconnectDelayMillis(-1).setImmediateFail(true).setName("TestApp").setImmediateFlush(true).setIgnoreExceptions(false).setFilter(null).setConfiguration(null).setAdvertise(false).setFacility(Facility.LOCAL0).setId("Audit").setEnterpriseNumber(18060).setIncludeMdc(true).setMdcId("RequestContext").setMdcPrefix(null).setEventPrefix(null).setNewLine(newLine).setAppName("TestApp").setMsgId("Test").setExcludes(null).setIncludeMdc(true).setRequired(null).setFormat(format1).setCharsetName(null).setExceptionPattern(null).setLoggerFields(null).build();
// @formatter:on
}
Aggregations