如何使用ASN1解码器(libtasn1-3.3)打印作为参数接收的DD证书pem的内容?
答案 0 :(得分:0)
asn1Decoding是来自libtasn1-3.3
的程序如果该程序适合你,那么ansn1Decoding有一个你可以使用的解码功能(当然你必须调整这个代码。如果你不想通过将解码代码移到你的程序来修改,然后你必须将解码代码复制到你的代码中):
static int
decode (asn1_node definitions, const char *typeName, void *der, int der_len,
int benchmark)
如果你想从程序中调用解码,那么你必须
asn1_node definitions = NULL;
int asn1_result = ASN1_SUCCESS;
unsigned char *der;
int der_len = 0, benchmark = 0;
// Please test with asn1Decoding application manually to find the correct typeName for your code
char typeName[] = {"PKIX1.Certificate"};
asn1_result = asn1_parser2tree ("Your File Name", &definitions, errorDescription);
if (asn1_result != ASN1_SUCCESS) { exit(1); }
{
size_t tmplen;
der = (unsigned char *) read_binary_file (inputFileDerName, &tmplen);
der_len = tmplen;
}
if (der == NULL)
{
asn1_delete_structure (&definitions);
exit (1);
}
if (decode (definitions, typeName, der, der_len, benchmark) != ASN1_SUCCESS)
{
asn1_delete_structure (&definitions);
}