HTTPSCodeTest.java
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* 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);
//
// }
}