der格式抛出crypto\u内部头太长错误

nhn9ugyo  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(128)

我正在尝试编写一个代码片段以der格式下载文件。
代码段:

public ResponseEntity<ByteArrayResource> downloadCertificate(final HttpServletResponse response){
certificateInputStream = fetchCertDataInDERFormat();

//create a file with contents
//        try {
//            File file = new File("<>/Downloads/byteCert.der");
//            OutputStream os = new FileOutputStream(file);
//            os.write(certInputStream.readAllBytes());
//            os.close();
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

HttpHeaders header = new HttpHeaders();
        header.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; headerCert.der");
        header.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
        ByteArrayResource resource = new ByteArrayResource(certificateInputStream.readAllBytes());
        return ResponseEntity.ok()
                .headers(header)
                .body(resource);
}

尝试用openssl命令检查响应体时抛出以下错误:
openssl x509-inform der-in certpostman.der-noout-subject-issuer无法加载证书4475899500:error:0dfff07b:asn1编码routines:crypto_internal:头太长:/appleinternal/buildroot/library/caches/com.apple.xbs/sources/libressl/libressl-47.140.1/libressl-2.8/crypto/asn1/asn1\u lib.c:152:
我决定的事情:
正文的内容很好,因为我能够成功地使用openssl检查bytecert.der(代码注解)的内容。
其他stackoverflow论坛中建议的任何spring标题(如内容处置、字符编码或内容类型更改)都没有帮助。
有谁能提出一些好的建议吗。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题