Hi,
 
It may be that you haven't added the digests in your application code.
 
When initialising OPenSSL it is necessary to add the digests and ciphers you intend to use - see the apps code ..add_all_digests or similar.
 
Regards,
Paul.
-----Original Message-----
From: Antonio Andrés Espallardo [mailto:[EMAIL PROTECTED]
Sent: 11 May 2004 11:51
To: [EMAIL PROTECTED]
Subject: Unknown Digest Type

Hi. Could anyone help me? I'm obtaining an error when I try to sign an ASN1
message with PKCS7_sign:
 

/***********************************************************************************/
/*This is the ASN1 message I need to sign*/
ASN1NegotiationRequest *prueba=nr->toASN1Object();
 
 Util *util = new Util();
 X509 *certificadoX509 = NULL;
 
/*This read a client certificate and store it in the variable
certificadoX509 */
 int salida = util->leerCertificadoX509("d:\\RafaCerJava.der",
&certificadoX509);
 
 if (salida != 1 )
  printf("Error al leer el certificado %d\n", salida);
 else
  printf("Certificado leido con exito\n");
 
 //Obtenemos la clave privada
  EVP_PKEY *evpPKey = EVP_PKEY_new();
 
/*This obtain the private key from a der file, and store it in the variable
evpPKey*/
 salida = util->readPrivateKey("d:\\RafaKeyJava.der",&evpPKey);
 
 if (salida != 1)
  printf("Error al obtener la clave privada %d\n", salida);
 else
  printf("%d\n", *evpPKey);
 
 //Certificados adicionales
  STACK_OF(X509) *certs;
 certs = sk_X509_new_null ();
 
 //Datos a firmar
  BIO *data = ""> int long_ = i2d_ASN1NegotiationRequest(prueba, NULL);
 
 int leidos = BIO_write(data, prueba, long_);
 
 BIO_flush(data);
 
 if (leidos <= 0)
  printf("Error al obtener el objeto BIO\n");
 else
  printf("Leidos : %d bytes %d\n",leidos, long_);
 
 //Entrando a firmar
 PKCS7 *signedData = PKCS7_sign(certificadoX509, evpPKey, certs, data, 0);
/***********************************************************************************/
 
Well, I obtain a NULL result from PKCS7_sign, and the reason I get with
ERR_error_string is : "error:2106906D:PKCS7 routines:PKCS7_dataInit:unknown
digest type". Does anyone knows what is happening please?. Thanks a lot

Reply via email to