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;
}