Fix DER certificate output on Windows

Fixes #10152

Signed-off-by: saadgodikat <saadgodikat601@gmail.com>
This commit is contained in:
saadgodikat 2026-09-25 21:30:16 +05:30
parent 3361ae00b4
commit 09cf58f2dd

View File

@ -238,7 +238,11 @@ static int write_certificate(mbedtls_x509write_cert *crt, const char *output_fil
output_start = output_buf; output_start = output_buf;
} }
if ((f = fopen(output_file, "w")) == NULL) { /*
* DER output is binary data. Use binary mode on Windows to prevent
* text-mode newline translation.
*/
if ((f = fopen(output_file, opt.format == FORMAT_DER ? "wb" : "w")) == NULL) {
return -1; return -1;
} }