0

Hy. I am trying to encode a ASN1 structure with DER , but i get a parse error. My in text is : 304913214D617374657220646520736563757269746174656120696E666F726D6174696569301E170D3039313030313030303030305A170D3130303331353030303030305A020103010101

and the code is this:

include <openssl/asn1.h>
#include <stdio.h>
#include<conio.h>
#include <string.h>
#include <iostream>
#include <fstream>
#pragma comment( lib, "libeay32.lib" )
using namespace std;

int main()
{
	unsigned char buffer[150];
	BIO * outfile;
	FILE* intext = fopen("bla.txt", "rb" );
	outfile=BIO_new_file("out.txt","w+");
	if (intext!=NULL)
	{
		fread(buffer, 150, 1, intext);
		fclose(intext);
	
		ASN1_parse(outfile,buffer,150,0);
	}
	else
		printf("error");
	BIO_free(outfile);
	return 0;
}

Edited by flaviusilaghi: n/a

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by flaviusilaghi
0

Where does the error occur? If it is on this call ASN1_parse() then you're question definitely needs to go to the OpenSSL community.

Dave

0

the error is that it doesn't parse right. The output looks like this: 0:d=0 hl=2 l= 48 cons: PRINTABLESTRING Error in encoding

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.