我正在尝试编写代码片段以下载 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:错误:0DFFF07B:asn1 编码例程:CRYPTO_internal:头文件太长:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.140.1/libressl-2.81/crypton1 .c:152:
我已经确定的事情:
任何人都可以提出任何好的意见。