I'm trying to build a program (trying with C#) that signs a document using a certificate inside a token. Have managed to build code that does it, but still I'm asked for the PIN. Sample of code follows below. Can anyone point out how to programmatically insert the code? rj ----------------------------------------------- public byte[] SignMsg(Byte[] msg, X509Certificate2 signerCert, bool detached) { ContentInfo contentInfo = new ContentInfo(msg); SignedCms signedCms = new SignedCms(contentInfo, detached); CmsSigner cmsSigner = new CmsSigner(signerCert); cmsSigner.IncludeOption = X509IncludeOption.EndCertOnly; signedCms.ComputeSignature(cmsSigner, false); return signedCms.Encode(); }
Is this cert coming from a Smart Card or is it a soft cert? ----- Dominick Baier (http://www.leastprivilege.com) Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp) > I'm trying to build a program (trying with C#) that signs a document > using a certificate inside a token. Have managed to build code that > does it, but still I'm asked for the PIN. Sample of code follows > below. Can anyone point out how to programmatically insert the code? > > rj > ----------------------------------------------- > public byte[] SignMsg(Byte[] msg, X509Certificate2 signerCert, bool > detached) > { > ContentInfo contentInfo = new ContentInfo(msg); > SignedCms signedCms = new SignedCms(contentInfo, > detached); > CmsSigner cmsSigner = new CmsSigner(signerCert); > cmsSigner.IncludeOption = X509IncludeOption.EndCertOnly; > signedCms.ComputeSignature(cmsSigner, false); > return signedCms.Encode(); > }
It's from a SafeNet iKey 2032 I've been able to use it from Java with no problems, but have had no success with .Net rj On 19 Fev, 20:00, Dominick Baier wrote: > Is this cert coming from a Smart Card or is it a soft cert? > > ----- > Dominick Baier (http://www.leastprivilege.com) > > Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)