SSLCertificateFile "/opt/apache/conf/cfca_server.crt"
#SSLCertificateFile "/opt/apache/conf/server.crt"
#SSLCertificateFile "/opt/apache/conf/server-dsa.crt"
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile "/opt/apache/conf/cfca_server.key"
#SSLCertificateKeyFile "/opt/apache/conf/server.key"
#SSLCertificateKeyFile "/opt/apache/conf/server-dsa.key"
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
#SSLCertificateChainFile "/opt/apache/conf/CFCA_RCA.cer
# Certificate Authority (CA):
# Set the CA certificate verification path where to find CA
# certificates for client authentication or alternatively one
# huge file containing all of them (file must be PEM encoded)
# Note: Inside SSLCACertificatePath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
SSLCACertificatePath "/opt/apache/conf"
#SSLCACertificateFile "/opt/apache/conf/ca.crt"
SSLCACertificateFile "/opt/apache/conf/cfca_root.crt"
maxThreads="150" scheme="https" secure="true"
clientAuth="true" sslProtocol="TLS"
keystoreFile="/home/cherubim/cert/cfca/cfcakeystore_server.jks" keystorePass="xxxxx"
truststoreFile="/home/cherubim/cert/cfca/cfcakeystore_server.jks" truststorePass="xxxxx"/>
port="8443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="/home/cherubim/cert/cfca/cfca_server.crt"
SSLCertificateKeyFile=/home/cherubim/cert/cfca/cfca_server.key"
clientAuth="optional" SSLProtocol="TLSv1"/>
openssl x509 -in cfca_root.crt -out cfca_root.der -outform DER
keytool -import -alias cfca_rca -keystore cfcakeystore_client.jks -import -trustcacerts -file CFCA_RCA.cer
keytool -import -alias cfca_root -keystore cfcakeystore_client.jks -import -trustcacerts -file cfca_root.der
keytool -importkeystore -v -srckeystore cfca_client.pfx -srcstoretype pkcs12 -srcstorepass 123456 -destkeystore cfcakeystore_client.jks -deststoretype jks
>keytool -list -v -keystore d:\cfcakeystore_all.jks
openssl pkcs12 -export -in cfca_server.crt -inkey cfca_server.key -out cfca_server.p12 -name cfca_server
openssl x509 -in cfca_root.crt -out cfca_root.der -outform DER
keytool -import -alias cfca_rca -keystore cfcakeystore_server.jks -import -trustcacerts -file CFCA_RCA.cer
keytool -import -alias cfca_root -keystore cfcakeystore_server.jks -import -trustcacerts -file cfca_root.der
keytool -importkeystore -v -srckeystore cfca_server.p12 -srcstoretype pkcs12 -srcstorepass xxxxx -destkeystore cfcakeystore_server.jks -deststoretype jks
package test;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2005
* Company:
* @author not attributable
* @version 1.0
*/
import java.net.*;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.Iterator;
import java.io.*;
import javax.net.ssl.HttpsURLConnection;
public class TestHttp {
public TestHttp() {
}
public static void main(String[] args) {
//TestHttp testHttp1 = new TestHttp();
try{
// System.setProperty("ssl.provider", "com.sun.net.ssl.internal.ssl.Provider ");
// System.setProperty("ssl.pkgs", "com.sun.net.ssl.internal.www.protocol");
System.setProperty("javax.net.ssl.keyStore","d:\\cfcakeystore_client.jks");
System.setProperty("javax.net.ssl.keyStorePassword","xxxxx");
System.setProperty("javax.net.ssl.trustStore","d:\\cfcakeystore_client.jks");
System.setProperty("javax.net.ssl.trustStorePassword","xxxxx");
URL url = new URL("https://xx.xxx.com:8443/docs");
// URL url = new URL("http://localhost:7001/test/newpageflow1/Newpageflow1Controller.jpf");
HttpsURLConnection uc=(HttpsURLConnection)url.openConnection();
System.out.println(url.toExternalForm());
//BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream()));
System.out.println("length"+uc.getContentLength());
System.out.println("/////////////"+uc.getContentType());
Map map=uc.getHeaderFields();
Iterator it=map.entrySet().iterator();
while(it.hasNext()){
System.out.println(it.next());
}
System.out.println("========"+uc.getHeaderField("Content-disposition"));
System.out.println(uc.getContent());
File file=new File("c:/xx.dat");
FileOutputStream fo=new FileOutputStream(file);
InputStream input=uc.getInputStream();
// ���������������
BufferedInputStream bis=null;
BufferedOutputStream bos=null;
try {
// ���������������
bis=new BufferedInputStream(uc.getInputStream());
bos=new BufferedOutputStream(fo);
// ���� Buffer
byte[] buff=new byte[1024];
int bytesRead;
int total=0;
PrintWriter pw=new PrintWriter(System.out);
// ��/дѭ����
while(-1!=(bytesRead=bis.read(buff,0,buff.length))) {
bos.write(buff,0,bytesRead);
bos.flush();
total+=bytesRead;
//pw.write(total+" bytes readed");
pw.flush();
}
} catch(IOException e){
// logger.debug("IOException. \n"+e.getMessage());
throw e;
} finally{
if(bis!=null) bis.close();
if(bos!=null) bos.close();
}
//
// do{
// tempStr=reader.readLine();
// System.out.println(tempStr);
// }while(tempStr!=null);
}catch(Exception e){
e.printStackTrace();
}
}
}
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyStore;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
public class TestHttps {
/**
* @param args
*/
public static void main(String[] args) {
DefaultHttpClient httpclient = new DefaultHttpClient();
FileInputStream instream = null;
FileInputStream instream2 = null;
KeyStore trustStore;
KeyStore keyStore;
try {
trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
instream = new FileInputStream(new File("d:\\cfcakeystore_client.jks"));
instream2 = new FileInputStream(new File("d:\\cfcakeystore_client.jks"));
trustStore.load(instream, "xxxxx".toCharArray());
keyStore.load(instream2, "xxxxx".toCharArray());
SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore,
"xxxxx", trustStore);
Scheme sch = new Scheme("https", socketFactory, 8443);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
HttpGet httpget = new HttpGet("https://xx.xxx.com:8443/docs");
System.out.println("executing request" + httpget.getRequestLine());
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: "
+ entity.getContentLength());
// entity.getContent().
entity.consumeContent();
}
httpclient.getConnectionManager().shutdown();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
instream.close();
instream2.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
java.security.cert.CertificateException: No subject alternative names present
172.17.249.48 xx.xxx.com
URL url = new URL("https://xx.xxx.com:8443/docs");