package thyyxxk.webserver.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.nio.file.Files;

/**
 * @author dj
 */
@Slf4j
public class WxCertUtil {
    public static final String APP_ID = "wxbde6b16acad84204";
    public static final String MERCHANT_ID = "1703306538";
    public static final String MERCHANT_KEY = "lilaiwflzIOLJI2320JLZL2Llisd02ak";
    public static final String CERT_PATH = "/home/zwxcert/new_merchant/apiclient_cert.p12";
//    public static final String CERT_PATH = "D:\\a.snapshot\\zwxcert\\new_merchant\\apiclient_cert.p12";

    public static byte[] CERTDATA;
    static {
        try {
            File file = new File(CERT_PATH);
            InputStream certStream = Files.newInputStream(file.toPath());
            CERTDATA = new byte[(int) file.length()];
            //noinspection ResultOfMethodCallIgnored
            certStream.read(CERTDATA);
            certStream.close();
        } catch (Exception e) {
            log.error("读取微信支付证书出错", e);
        }
    }
    public InputStream getCertStream() {
        return new ByteArrayInputStream(CERTDATA);
    }
}
