Hello,
I have created an ASP page that requests special V2.0 Certificates for a user.
This is to use with our VPN solution.
My code errors on this line:
requeststr = CertEnroll.crea teRequest(XECR_ CMC,dn, "")
This ASP page/Application has anonymous disabled and has Basic
Authentication Configured with SSL.
When I run this ASP page from any browser it gives me an '80070002' error.
But very strange is that from the moment that I logon via Terminal Session
to the Webserver with the user account logged into the web page my web page
runs fine (still running IE on workstation not on Server, I repeat the same
task again on the client)
So I checked some things and The requesting users have log on locally and
log on with terminal services.
This has me puzzled and I don't know what to do.
It Seems that the createrequest function needs something in the users
profile? Or Temp directory? Even with an enterprise admin account I have the
same error.
Does anyone know how to solve this?
Some searching on the internet found this but there is no workarround or
solution!
I have the error similar to this one:
http://groups.google.be/group/micros...1d12a78d980f86
Full Function is below
sub CreateCert(dn,d ispl)
Const AT_KEYEXCHANGE = 1
Const XECR_PKCS10_V2_ 0 = 1
Const XECR_CMC = 3
Const CR_IN_ENCODEANY = &HFF
Const CR_IN_FORMATANY = &H0
Const CR_DISP_ISSUED = &H3
Const FR_PROP_FULLRES PONSE = &H1
Const FR_PROP_ISSUEDC ERTIFICATE = &H11
Const CR_OUT_BASE64 = &H1
Const PROPTYPE_BINARY = &H3
Set CertEnroll = Server.CreateOb ject("CEnroll.C Enroll")
CertEnroll.Prov iderName = "Microsoft Enhanced Cryptographic Provider v1.0"
CertEnroll.KeyS pec = AT_KEYEXCHANGE
CertEnroll.GenK eyFlags = 1024 * (256 *256) +1
CertEnroll.addC ertTypeToReques t(CertificateTe mplate)
Set CertRequest = Server.CreateOb ject("Certifica teAuthority.Req uest")
'Response.Write "<br>" & dn
'requeststr =
CertEnroll.crea teRequest(XECR_ CMC,dn,"1.3.6.1 .5.5.7.3.2,1.3. 6.1.5.5.7.3.4")
requeststr = CertEnroll.crea teRequest(XECR_ CMC,dn, "")
'Response.Write "<br>" & err.Description & " : " & err.number & " : " &
err.Source
'Response.Write "<br>" & dn
'WScript.Echo requeststr
disposition = CertRequest.Sub mit(CR_IN_ENCOD EANY Or CR_IN_FORMATANY ,
requeststr, "", CAConfig)
ID = CertRequest.Get RequestId()
'WScript.Echo ID
If disposition = CR_DISP_ISSUED Then
Dim Cert
Cert =
CertRequest.Get FullResponsePro perty(FR_PROP_F ULLRESPONSE,0,P ROPTYPE_BINARY,
CR_OUT_BASE64)
CertEnroll.acce ptResponse Cert
Cert = CertRequest.Get Certificate(CR_ OUT_BASE64)
'Response.Write Cert
set certif = Server.CreateOb ject("CAPICOM.C ertificate")
certif.import Cert
'Response.Write "<br>Valid To : " & certif.ValidToD ate
SetSerialInAd dn,certif.Seria lNumber
SetExpirationIn Ad dn,Cstr(certif. ValidToDate)
Dim filename
filename = CertificatesPat h & displ & ".pfx"
Dim fso
Set fso = CreateObject("S cripting.FileSy stemObject")
If (fso.FileExists (filename)) Then
fso.DeleteFile filename,true
End If
CertEnroll.crea teFilePFX PfxPassword,fil ename
response.Write "<div class='Box'>"
Response.Write GenerateTableLi ne ("GoLtrHS.gif", "Certificat e was created
Successfully!")
Response.Write "<br><br>" & GenerateTableLi ne ("infoBubble.gi f","User :
" & displ)
Response.Write GenerateTableLi ne ("infoBubble.gi f","<a href='pfx/" &
displ & ".pfx'>Down load Certificate File</a>")
'Response.Write "<img src='Images/GoLtrHS.gif'/> Certificate was created
Successfully!"
'Response.Write "<br><br>Us er : " & displ
'Response.Write "<br><a href='pfx/" & displ & ".pfx'>Down load Certificate
File</a>"
Else
GenerateError CStr(CertReques t.GetLastStatus ())
End if
end sub