|
Dear All,
I am getting the following error while using a private key in
my openSSL based application
1700:error:0D080071:asn1 encoding
routines:d2i_ASN1_INTEGER:expecting an
integer:.\crypto\asn1\a_int.c:204:
1700:error:0D08A082:asn1 encoding routines:d2i_DSAPrivateKey:parsing:.\crypto\asn1\d2i_s_pr.c:101: 1700:error:0D09B00D:asn1 encoding routines:d2i_PrivateKey:ASN1 lib:.\crypto\asn1\d2i_pr.c:98: 1700:error:140AF00D:SSL routines:SSL_CTX_use_PrivateKey_ASN1:ASN1 lib:.\ssl\ssl_rsa.c:728: However the same private key works in my Java application
using Phaos SSLava toolkit. The private key is in PKCS8 encrypted DER format. It
however works if I convert it into PEM format using PKCS8 command. Any pointers
where I am doing wrong. The following are the code snippets from both C and Java
applications.
C:
fp = fopen(keyFile, "rb");
if (fp == NULL) exit(1); len = fread(buff, sizeof(unsigned char), sizeof(buff)-1, fp); fclose(fp); if (SSL_CTX_use_PrivateKey_ASN1(EVP_PKEY_DSA, ctx, buff,
len) <=
0)
{ ERR_print_errors_fp(stderr); exit (1); } Java:
crysec.SSL.SSLCertificate cert = new
crysec.SSL.SSLCertificate();
cert.privateKey = (new PrivateKeyPKCS8("test", new File(path +
File.separator + "enc-dsa-server-key.der"))).getKey();
Thanks
Nitin
|
