[Mono-list] Unknown hash algorithm

Martín Trejo Chávez mtrejoch at ownmail.net
Wed May 3 15:33:59 EDT 2006


I've been working in a proyect where is required to extract the user certificate and his private key from a .pfx file. After have looked at certmgr and makecert code, finally I made a class to do the task.

I use a X509CertificateBuilder to receive the values from the user's certificate, just transfer for one side to another:

  builder.SerialNumber = userCertificate.SerialNumber;
  builder.IssuerName = userCertificate.IssuerName;
  builder.NotBefore = userCertificate.ValidFrom; 
  builder.NotAfter = userCertificate.ValidUntil; 
  builder.SubjectName = userCertificate.SubjectName;
  builder.SubjectPublicKey = aa; 
  builder.Hash = userCertificate.SignatureAlgorithm; 

  byte[] rawcert = builder.Sign(aa);

The problem arise from the las line, as it's run throws this exception:

Unknown hash algorithm 1.2.840.113549.1.1.5
in <0x000ee> Mono.Security.X509.X509Builder:GetOid (System.String hashName)
in <0x00038> Mono.Security.X509.X509Builder:Sign (System.Security.Cryptography.RSA key)
in <0x0004d> Mono.Security.X509.X509Builder:Sign (System.Security.Cryptography.AsymmetricAlgorithm aa)
in <0x00466> PfxManager:ExtractCertificate ()
in <0x0002f> PfxManagerTest:Main (System.String[] args)

This is for Mono, Mono 1.1.15 and .NET 1.1

I've already found the description of the OID at http://www.alvestrand.no/objectid/1.2.840.113549.1.1.5.html.

Now, this simply means that as the hash algorithm is unknown I'm stuck 'til here? I'm not very cripto-proficient so the idea of building a hash algorithm implementation really scares me, besides, there is no time :P

Any comments, guidance and/or help would be appreciated.


Martín Trejo Chávez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20060503/2ebde2ca/attachment.html

More information about the Mono-list mailing list