Wrox Home  
Search P2P Archive for: Go

  Return to Index  

security_asp thread: failed to acquire a handle to the DEFAULT key container


Message #1 by "Andrew Teoh" <andrew_tbj@f...> on Thu, 15 Nov 2001 16:31:17 +0800
This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C16DF2.F38DBC30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

MessageHi,
I'm trying to create a simple encryption and decryption programe using  
CryptoAPI in VB, it runs fine in desktop version under win 98 and win 
2000 professional.

But the problem occured when i converted it into activeX dll (com 
object) which embeded into ASP file. When I ran the asp file, the error 
message showed it failed to acquire a handle to the DEFAULT (56-bit) key 
container in IIS, win 2000. But it worked fine in PWS win98.   

The code is in below:

 Private m_lngCryptContext  As Long
 Private strTmp As String =3D ""
 Dim strProvider2  As String
 strProvider2 =3D MS_DEFAULT_PROVIDER & vbNullChar

 If Not CBool(CryptAcquireContext(m_lngCryptContext, strTmp, 
strProvider2, PROV_RSA_FULL, 0)) Then
      ' Create default key container.
      If Not CBool(CryptAcquireContext(m_lngCryptContext, strTmp, 
strProvider2, PROV_RSA_FULL, CRYPT_NEWKEYSET)) Then
          strErrorMsg =3D "Error creating DEFAULT key container - " & 
CStr(Err.LastDllError)
          m_ErrInit =3D strErrorMsg
          Initialize_CryptoAPI =3D False
          Exit Function
      End If
  End If

I have given all neccesary full control right to internet user account 
but it was still failed.

Please help,

Thank you

Regards,
Andrew 





  Return to Index