smime con mono.

Jonatan Anauati <[email protected]>
Newsgroups gmane.comp.gnome.mono.hispano
Message-ID <1231704423.4728.17.camel@dino-thunder_ng>
Buenas tardes a todos, estoy intentando calcular la firma de un mensaje
con el siguiente codigo:

public static byte[] Sign
    (String pkcs12Path, 
    string password, 
    string message)
    {
	X509Certificate2 cert;
	if (password == null)
	    cert= new X509Certificate2 (pkcs12Path);
	else
	    cert= new X509Certificate2  (pkcs12Path, password);
	ContentInfo content = new ContentInfo
(System.Text.Encoding.Default.GetBytes (message));
	SignedCms signedCms = new SignedCms (content, false);
	CmsSigner signer = new 	CmsSigner (cert);
	signedCms.ComputeSignature (signer);
	return signedCms.Encode ();
}

cuando utilizo este metodo obtengo la siguiente excepcion:

Unhandled Exception:
System.Security.Cryptography.CryptographicException: Input data cannot
be coded as a valid certificate. ---> System.NotSupportedException:
Undefined length encoding.
  at Mono.Security.ASN1..ctor (System.Byte[] data) [0x00000]
  at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data)
[0x00000]
  --- End of inner exception stack trace ---
  at Mono.Security.X509.X509Certificate.Parse (System.Byte[] data)
[0x00000]
  at Mono.Security.X509.X509Certificate..ctor (System.Byte[] data)
[0x00000]
  at
System.Security.Cryptography.X509Certificates.X509Certificate.Import
(System.Byte[] rawData, System.String password, X509KeyStorageFlags
keyStorageFlags) [0x00000]
  at
System.Security.Cryptography.X509Certificates.X509Certificate2.Import
(System.Byte[] rawData, System.String password, X509KeyStorageFlags
keyStorageFlags) [0x00000]
  at
System.Security.Cryptography.X509Certificates.X509Certificate2.Import
(System.String fileName, System.String password, X509KeyStorageFlags
keyStorageFlags) [0x00000]
  at
System.Security.Cryptography.X509Certificates.X509Certificate2..ctor
(System.String fileName, System.String password) [0x00000]
  at Smime.Signer.Sign (System.String pkcs12Path, System.String
password, System.String message) [0x00000]

Agrego que el archivo pkcs12 que utilizo para las pruebas es valido, 
ya que es el mismo que utilizo normalmente para firmar mensajes
de email.

Espero comentarios, muchas gracias.

-- 
por favor evita el enviarme archivos adjuntos de MS Word. 
Ver:http://www.gnu.org/philosophy/no-word-attachments.es.html
printk("fent linux\n");

_______________________________________________
Mono-hispano mailing list
[email protected]
https://listas.hispalinux.es/mailman/listinfo/mono-hispano
smime.p7s (application/x-pkcs7-signature, 3.4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.