先上代码
public class HttpsUtil {
private Logger logger = LoggerFactory.getLogger(HttpsUtil.class);
private static final ClassPathResource KEY_STORE_CLIENT_PATH = new ClassPathResource("ca/client.p12");
private static final String KEY_STORE_TYPE_JKS = "JKS";
private static final String KEYSTORE_PASSWORD = "123456";
private CloseableHttpClient httpClient;
public HttpsUtil() throws Exception {
KeyStore keyStore = KeyStore.getInstance(KEY_STORE_TYPE_JKS);
KeyStore trustKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
InputStream instream = KEY_STORE_CLIENT_PATH.getInputStream();
try {
keyStore.load(instream, KEYSTORE_PASSWORD.toCharArray());
} catch (CertificateException e) {
logger.error("加载客户端端可信任证书出错了", e);
} finally {
try {
instream.close();
} catch