broker/DefaultMoquetteSslContextCreator: code formatter used
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
*
|
*
|
||||||
* You may elect to redistribute this code under either of these licenses.
|
* You may elect to redistribute this code under either of these licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.moquette.server;
|
package io.moquette.server;
|
||||||
|
|
||||||
import io.moquette.BrokerConstants;
|
import io.moquette.BrokerConstants;
|
||||||
@@ -20,20 +21,18 @@ import io.moquette.server.config.IConfig;
|
|||||||
import io.moquette.spi.security.ISslContextCreator;
|
import io.moquette.spi.security.ISslContextCreator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.net.ssl.KeyManagerFactory;
|
import javax.net.ssl.KeyManagerFactory;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.TrustManagerFactory;
|
import javax.net.ssl.TrustManagerFactory;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moquette server implementation to load SSL certificate from local filesystem path
|
* Moquette server implementation to load SSL certificate from local filesystem path configured in
|
||||||
* configured in config file.
|
* config file.
|
||||||
*
|
*
|
||||||
* Created by andrea on 13/12/15.
|
* Created by andrea on 13/12/15.
|
||||||
*/
|
*/
|
||||||
@@ -90,9 +89,11 @@ class DefaultMoquetteSslContextCreator implements ISslContextCreator {
|
|||||||
TrustManager[] trustManagers = null;
|
TrustManager[] trustManagers = null;
|
||||||
if (needsClientAuth) {
|
if (needsClientAuth) {
|
||||||
LOG.warn(
|
LOG.warn(
|
||||||
"Client authentication is enabled. The keystore will be used as a truststore. KeystorePath = {}.",
|
"Client authentication is enabled. "
|
||||||
|
+ "The keystore will be used as a truststore. KeystorePath = {}.",
|
||||||
jksPath);
|
jksPath);
|
||||||
// use keystore as truststore, as server needs to trust certificates signed by the server certificates
|
// use keystore as truststore, as server needs to trust certificates signed by the
|
||||||
|
// server certificates
|
||||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
tmf.init(ks);
|
tmf.init(ks);
|
||||||
trustManagers = tmf.getTrustManagers();
|
trustManagers = tmf.getTrustManagers();
|
||||||
@@ -105,7 +106,10 @@ class DefaultMoquetteSslContextCreator implements ISslContextCreator {
|
|||||||
return serverContext;
|
return serverContext;
|
||||||
} catch (NoSuchAlgorithmException | UnrecoverableKeyException | CertificateException | KeyStoreException
|
} catch (NoSuchAlgorithmException | UnrecoverableKeyException | CertificateException | KeyStoreException
|
||||||
| KeyManagementException | IOException ex) {
|
| KeyManagementException | IOException ex) {
|
||||||
LOG.error("Unable to initialize SSL context. Cause = {}, errorMessage = {}.", ex.getCause(), ex.getMessage());
|
LOG.error(
|
||||||
|
"Unable to initialize SSL context. Cause = {}, errorMessage = {}.",
|
||||||
|
ex.getCause(),
|
||||||
|
ex.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user