资源简介
注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的
代码片段和文件信息
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License Version 2.0 (the
* “License“); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing
* software distributed under the License is distributed on an
* “AS IS“ BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation please see
* .
*
*/
package com.utils;
import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
/**
* This example demonstrates how to create secure connections with a custom SSL
* context.
*/
public class ClientCustomSSL {
public static String doRefund(String urlString data) throws Exception {
/**
* 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的
*/
KeyStore keyStore = KeyStore.getInstance(“PKCS12“);
FileInputStream instream = new FileInputStream(new File(“D:/Program Files/MyEclipse 6.5/workspace/weidian/WebRoot/cer/apiclient_cert.p12“));//P12文件目录
try {
/**
* 此处要改
* */
keyStore.load(instream “1232309302“.toCharArray());//这里写密码..默认是你的MCHID
} finally {
instream.close();
}
// Trust own CA and all self-signed certs
/**
* 此处要改
* */
SSLContext sslcontext = SSLContexts.custom()
.loadKeyMaterial(keyStore “1232309302“.toCharArray())//这里也是写密码的
.build();
// Allow TLSv1 protocol only
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext
new String[] { “TLSv1“ }
null
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-05-22 12:05 testWeixinRefund\
文件 1140 2015-05-18 18:24 testWeixinRefund\.classpath
目录 0 2015-05-22 12:05 testWeixinRefund\.myeclipse\
文件 321 2015-05-22 11:34 testWeixinRefund\.myme
文件 1018 2015-05-18 18:17 testWeixinRefund\.project
目录 0 2015-05-22 12:05 testWeixinRefund\.settings\
文件 209 2015-05-19 14:47 testWeixinRefund\.settings\org.eclipse.core.resources.prefs
目录 0 2015-05-22 12:05 testWeixinRefund\src\
目录 0 2015-05-22 12:05 testWeixinRefund\src\com\
目录 0 2015-05-22 12:05 testWeixinRefund\src\com\utils\
文件 4426 2015-05-22 12:05 testWeixinRefund\src\com\utils\ClientCustomSSL.java
文件 1157 2015-05-18 14:05 testWeixinRefund\src\com\utils\MD5Util.java
文件 6612 2015-05-18 14:05 testWeixinRefund\src\com\utils\RequestHandler.java
文件 2098 2015-05-18 14:05 testWeixinRefund\src\com\utils\Sha1Util.java
文件 3682 2015-05-18 14:05 testWeixinRefund\src\com\utils\TenpayUtil.java
目录 0 2015-05-22 12:05 testWeixinRefund\src\com\wechat\
文件 2226 2015-05-22 12:02 testWeixinRefund\src\com\wechat\Refund.java
目录 0 2015-05-22 12:05 testWeixinRefund\WebRoot\
文件 834 2015-05-18 18:17 testWeixinRefund\WebRoot\index.jsp
目录 0 2015-05-22 12:05 testWeixinRefund\WebRoot\me
文件 39 2015-05-18 18:17 testWeixinRefund\WebRoot\me
目录 0 2015-05-22 12:05 testWeixinRefund\WebRoot\WEB-INF\
目录 0 2015-05-22 12:05 testWeixinRefund\WebRoot\WEB-INF\classes\
目录 0 2015-05-22 12:05 testWeixinRefund\WebRoot\WEB-INF\classes\com\
目录 0 2015-05-22 12:05 testWeixinRefund\WebRoot\WEB-INF\classes\com\utils\
文件 4064 2015-05-22 12:05 testWeixinRefund\WebRoot\WEB-INF\classes\com\utils\ClientCustomSSL.class
文件 2154 2015-05-18 18:24 testWeixinRefund\WebRoot\WEB-INF\classes\com\utils\MD5Util.class
文件 6325 2015-05-19 14:47 testWeixinRefund\WebRoot\WEB-INF\classes\com\utils\RequestHandler.class
文件 3369 2015-05-18 18:24 testWeixinRefund\WebRoot\WEB-INF\classes\com\utils\Sha1Util.class
文件 3396 2015-05-18 18:24 testWeixinRefund\WebRoot\WEB-INF\classes\com\utils\TenpayUtil.class
目录 0 2015-05-22 12:05 testWeixinRefund\WebRoot\WEB-INF\classes\com\wechat\
............此处省略13个文件信息
- 上一篇:glide-3.7.0.jar
- 下一篇:基于jsp的投票系统
评论
共有 条评论