cert_write tool generates invalid der file (Visual Studio 2022)
Summary
Using visual studio 2022 under Win11 cert_write creates invalid files for der format.
System information
Mbed TLS version 3.6.3: Operating system and version: Windows 11 Compiler and options: Visual Studio 2022
Steps to reproduce
Use cert_write and create format=der cert_write subject_key=subject.key issuer_key=subject.key output_file=cert.der subject_name="CN=MyCert,O=MyOrg,C=US" issuer_name="CN=MyCert,O=MyOrg,C=US" not_before=20250101000000 not_after=20300101000000 serial=12345 selfsign=1 is_ca=1 md=SHA256 format=der
. Seeding the random number generator... ok . Reading serial number... ok . Loading the issuer key ... ok . Setting certificate values ... ok . Adding the Basic Constraints extension ... ok . Adding the Subject Key Identifier ... ok . Adding the Authority Key Identifier ... ok . Writing the certificate... ok
check: openssl x509 -inform DER -in cert.der -text -noout Could not read certificate from cert.der Unable to load certificate
Creation of pem file is working and creates valid file. For der format file must be opened binary ("wb"). As a beginner I used cert_write as sample and documentation, it took some time to figure this out.
Source: Mbed-TLS/mbedtls