HTTPSCodeTest.java 1.01 KB


/**
 * Created by david on 2015/11/10.
 */
public class HTTPSCodeTest {

//	//密钥库、信任库密码
//	private String password = "123456";
//
//	//密钥库文件路径
//	private String keyStorepath = "d:/zlex.keystore";
//
//	//信任库文件路径
//	private String trustStorePath = "d:/zlex.keystore";
//
//	//访问地址
//	private String httpsUrl = "https://pay.nong12.com";
//
//	@Test
//	public void test() throws Exception {
//		URL url = new URL(httpsUrl);
//
//		HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
//		conn.setDoInput(true);
//		HTTPSCoder.configSSLSocketFactory(conn, password, keyStorepath, trustStorePath);
//		//鉴别内容长度
//		int length = conn.getContentLength();
//		byte[] data = null;
//		if (length != -1) {
//			DataInputStream dis = new DataInputStream(conn.getInputStream());
//			data = new byte[length];
//			dis.readFully(data);
//			dis.close();
//			System.err.println(new String(data));
//		}
//		conn.disconnect();
//		Assert.assertNotNull(data);
//
//	}
}