Replies: 4 comments 12 replies
-
In fact, Botan reads BER but emits DER (which is a restricted subset of BER), even though the method Though, I have a hunch you might actually mean to convert from DER to PEM, or vice versa. Here's some code that reads a X.509 certificate in either PEM or BER and emits it in both formats: #include <iostream>
#include <botan/hex.h>
#include <botan/x509cert.h>
int main() {
auto cert = Botan::X509_Certificate("some_cert.pem");
std::cout << cert.PEM_encode() << std::endl;
std::cout << Botan::hex_encode(cert.BER_encode()) << std::endl;
} The output will be something like:
|
Beta Was this translation helpful? Give feedback.
-
Well actually I don't need to convert from DER to PEM, the best option would be to generate certificate in DER format. Currently I'm doing something like this:
and writing it into certificate file. And certificate is written fine. But when I read it in a specific program that reads certificates in DER format, it gives an error. Although, when I transform this certificate in openssl using But I would like to achieve this result with Botan, maybe I'm doing something wrong? |
Beta Was this translation helpful? Give feedback.
-
However, I have observed another thing, that transforming generated certificate with DER_encoder:
and writing it into file, the output is as expected, certificate is generated with parameters I want. But, reading the same freshly generated certificate with: throws an error. Any suggestions? |
Beta Was this translation helpful? Give feedback.
-
I have a hard time making sense of your findings in the implementation, frankly. You state that the result of However, the implementation of botan/src/lib/asn1/asn1_obj.cpp Lines 19 to 24 in 7f15ce7 ... and literally does the same thing as the manual Could you post a full and runnable reproducer for your problem? |
Beta Was this translation helpful? Give feedback.
-
Hi! Is there a way using Botan to transform X509 certificate in BER encoding into DER encoding?
Beta Was this translation helpful? Give feedback.
All reactions