Skip to content

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

Closed

Description

@jianchengwang

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

Activity

  1. binarywang commented on Apr 18, 2022

    @binarywang
    Owner

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

  2. added this to the 4.3.2 milestone on Apr 25, 2022
  3. added a commit that references this issue on Apr 25, 2022
  4. z-xiaohua commented on Feb 13, 2023

    @z-xiaohua

    使用以下代码获取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));
    
  5. binarywang commented on Feb 14, 2023

    @binarywang
    Owner

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

  6. Repository owner locked as resolved and limited conversation to collaborators on Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions