Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apiclient_cert.p12 可以用base64 编码存储加载吗 #2586

Closed
jianchengwang opened this issue Apr 13, 2022 · 3 comments
Closed

apiclient_cert.p12 可以用base64 编码存储加载吗 #2586

jianchengwang opened this issue Apr 13, 2022 · 3 comments
Milestone

Comments

@jianchengwang
Copy link

apiclient_cert.p12 可以用base64 编码存储加载吗,比较文件不好存储管理,

@binarywang
Copy link
Member

你希望怎么存储,欢迎直接PR代码

@z-xiaohua
Copy link

z-xiaohua commented Feb 13, 2023

使用以下代码获取p12证书的字节数组内容和Base64编码内容,供后来者参考

    File file = new File("D://apiclient_cert.p12");
    InputStream inputStream = new FileInputStream(file);
    // 获取p12证书文件内容的字节数组.
    byte[] keyContent = IOUtils.toByteArray(inputStream);

    // 获取p12证书base64编码
    String keyString = Base64.getEncoder().encodeToString(keyContent);
    System.out.println(keyString);

    // 检验Base64解密后是否相同
    byte[] configContent = Base64.getDecoder().decode(keyString);
    System.out.println(Arrays.equals(keyContent, configContent));

@binarywang
Copy link
Member

请参考commit记录,代码里已经支持

@Wechat-Group Wechat-Group locked as resolved and limited conversation to collaborators Feb 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants