| | |
| | | package com.ruoyi.shop.util; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.shop.util.dto.CertificateItem; |
| | | import com.ruoyi.shop.util.dto.EncryptedCertificateItem; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.apache.http.Header; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @date 2020-03-18 15:06 |
| | |
| | | * @param savePath |
| | | * @return |
| | | */ |
| | | public static List<X509Certificate> getCertByAPI(String merchantId, int timeout, String serialNo, String mchPrivateKeyPath, String wechatPubKeyPath, String APIv3Key, String savePath) { |
| | | /*public static List<X509Certificate> getCertByAPI(String merchantId, int timeout, String serialNo, String mchPrivateKeyPath, String wechatPubKeyPath, String APIv3Key, String savePath) { |
| | | String result = ""; |
| | | //创建http请求 |
| | | HttpGet httpGet = new HttpGet("https://api.mch.weixin.qq.com/v3/certificates"); |
| | |
| | | } |
| | | logger.info("证书List:" + certList); |
| | | |
| | | /*List<PlainCertificateItem> plainList = decrypt(certList, APIv3Key); |
| | | *//*List<PlainCertificateItem> plainList = decrypt(certList, APIv3Key); |
| | | if (CollectionUtils.isNotEmpty(plainList)) { |
| | | logger.info("平台证书开始保存"); |
| | | x509Certs = saveCertificate(plainList, savePath); |
| | | }*/ |
| | | }*//* |
| | | } |
| | | } |
| | | } |
| | |
| | | logger.error("下载平台证书返回结果:" + e); |
| | | } |
| | | return x509Certs; |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | /*private static List<PlainCertificateItem> decrypt(List<CertificateItem> certList,CloseableHttpResponse response) throws GeneralSecurityException, IOException { |