problems with



Hello security experts :)

Does any one know how to solve problem with generating incorrect *.p7b
files using ICertRequest2::GetCertificate ?

Dim rgByte(ct) As Byte
objXen.SPCFileName = strCertPathP7b
strNewCert = objRequest.GetCertificate(CR_OUT_BASE64HEADER Or _
CR_OUT_CHAIN)

ct = strNewCert.Length * 2
rgByte =
System.Text.Encoding.Default.GetBytes(strNewCert.ToCharArray())
objXen.acceptPKCS7(rgByte2)

If I use this code above (form example in msdn) than generate file is
OK, but contains chain of certificates and it's impossible than to
create .pfx file from it; getting Exception "Cannot find the requested
object"

on line:
objXen.getCertFromPKCS7(issuedCert)

where IssuedCert is from:
objXen = CreateObject("CEnroll.CEnroll.1")
Button2.PerformClick()
fi = New System.IO.FileInfo(strCertPathP7b)
fStream = fi.OpenRead()
Dim buff(fi.Length) As Byte
fStream.Read(buff, 0, buff.Length)

issuedCert = Convert.ToBase64String(buff)

But if I try to write only one certificate in a .p7b file:
strNewCert2 = objRequest.GetCertificate(CR_OUT_BASE64HEADER)
it's impossible to make pfx form it because of the same Exception on:
objXen.getCertFromPKCS7(issuedCert)

Also if i try to view te certifcate manually there is System warning:
This file is invalid for use as folollowing: PKCS#7
But if I manually export issued certificate from Win2003 standalone CA
and try to generate PFX from it from my application than everything is
OK :|

It's seems it is plain certificate in X.509 format, but how to convert
it to PKCS#7?

Any ideas where am I wrong?

Regards,
rybasso

.


Quantcast