From 2b61d520c7174131e59ff7e86cf55d5e23fef8fb Mon Sep 17 00:00:00 2001 From: weixing Date: Tue, 5 Jun 2018 09:07:43 +0800 Subject: [PATCH] [SCB-350] if the file not exist, make a warn log to trace it. make the error more clearly --- .../foundation/vertx/VertxTLSBuilder.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxTLSBuilder.java b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxTLSBuilder.java index 9b7fd28d177..bd6642b288b 100644 --- a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxTLSBuilder.java +++ b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/VertxTLSBuilder.java @@ -23,6 +23,8 @@ import org.apache.servicecomb.foundation.ssl.SSLManager; import org.apache.servicecomb.foundation.ssl.SSLOption; import org.apache.servicecomb.foundation.ssl.SSLOptionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import io.vertx.core.http.ClientAuth; import io.vertx.core.http.HttpClientOptions; @@ -34,6 +36,8 @@ import io.vertx.core.net.TCPSSLOptions; public final class VertxTLSBuilder { + private static final Logger LOGGER = LoggerFactory.getLogger(VertxTLSBuilder.class); + private static final String STORE_PKCS12 = "PKCS12"; private static final String STORE_JKS = "JKS"; @@ -93,7 +97,8 @@ private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom s options.setSessionCacheEnabled(true); tcpClientOptions.setOpenSslEngineOptions(new OpenSSLEngineOptions()); } - if (isFileExists(sslCustom.getFullPath(sslOption.getKeyStore()))) { + String fullKeyStore = sslCustom.getFullPath(sslOption.getKeyStore()); + if (isFileExists(fullKeyStore)) { if (STORE_PKCS12.equalsIgnoreCase(sslOption.getKeyStoreType())) { PfxOptions keyPfxOptions = new PfxOptions(); keyPfxOptions.setPath(sslCustom.getFullPath(sslOption.getKeyStore())); @@ -107,9 +112,11 @@ private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom s } else { throw new IllegalArgumentException("invalid key store type."); } + } else { + LOGGER.warn("keyStore [" + fullKeyStore + "] file not exist, please check!"); } - - if (isFileExists(sslCustom.getFullPath(sslOption.getTrustStore()))) { + String fullTrustStore = sslCustom.getFullPath(sslOption.getTrustStore()); + if (isFileExists(fullTrustStore)) { if (STORE_PKCS12.equalsIgnoreCase(sslOption.getTrustStoreType())) { PfxOptions trustPfxOptions = new PfxOptions(); trustPfxOptions.setPath(sslCustom.getFullPath(sslOption.getTrustStore())); @@ -125,6 +132,8 @@ private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom s } else { throw new IllegalArgumentException("invalid trust store type."); } + } else { + LOGGER.warn("trustStore [" + fullTrustStore + "] file not exist, please check!"); } for (String protocol : sslOption.getProtocols().split(",")) { tcpClientOptions.addEnabledSecureTransportProtocol(protocol);