Archived Forum Post

Index of archived forum posts

Question:

ChilkatPfx and Terminal Services RemoteApp

Feb 22 '13 at 07:12

Hi all, and thank you for reading my post. I'm running an application in Terminal Services RemoteApp that requires a digital certificate to be installed. User profiles are reset every day, so in order for the application to run, I have to re-install the .pfx certificate. If I install the .pfx manually, my application detects that the certificate is installed and runs, but if I install the .pfx file using ChilkatPFX, my application doesn't detect the digital certificate.

Can you guys give me any hint on what I'm doing wrong?

Here's the FoxPro code that I'm using

Local loPFX
Local lnSuccess
TRY
loPFX=CreateObject("Chilkat.pfx")
loPFX.UnlockComponent('MyLicenceKey')
pfxFilename="\\srv-phc-01\Certificados\saphety.pfx"
password="MyPassword"
machineKeyset=1
localMachineCertStore=0
markExportable=1
useWarningDialog=0
lnSuccess=loPFX.ImportPfxFile(pfxFilename, password, machineKeyset, localMachineCertStore, markExportable, useWarningDialog)

if lnSuccess=0
    user_SendLOG("Certificado Saphety", loPFX.LastErrorText)
Else
    user_SaveLog("Certificado Saphety", loPFX.LastErrorText)
    Endif

CATCH TO ex
    user_SendLOG("Certificado Saphety", ex.message)
ENDTRY

And here's the LastErrorText:

ChilkatLog:
  ImportPfxFile:
    DllDate: Mar 26 2010
    Username: MyUser
    filename: \\srv-phc-01\Certificados\saphety.pfx
    machineKeyset: 1
    localMachine: 0
    exportable: 1
    warningDialog: 0
    Loaded the PFX file into memory...
    Password verified.
    adding_cert: Certificate Root 03, Trusted Services SA
    cert_store_location: (registry) HKEY_CURRENT_USER/[Current User Certificate Store]
    Successfully added certificate to certificate store.
    adding_cert: Certificate 05, Trusted Services SA
    cert_store_location: (registry) HKEY_CURRENT_USER/[Current User Certificate Store]
    Successfully added certificate to certificate store.
    adding_cert: MyCompany Certificate, My Company SA
    cert_store_location: (registry) HKEY_CURRENT_USER/[Current User Certificate Store]
    Successfully added certificate to certificate store.

Answer

The import appears to be successful to the Current User certificate store. Some ideas:

  1. Maybe you need to use the Local Machine certificate store (localMachineCertStore=1).
  2. If you really want to use the current user store, you need to confirm that your app is running under the expected user account so that the Current User store matches your desired user store.

Answer

Hi jpbro, thanks for your answer.

1) I tried Local Machine Certificate Store, but it returns 0-"Access Denied", although I'm running this as machine administrator on my development environment. Final users accessing the application via RemoteApp will not be administrators.

ChilkatLog:
ImportPfxFile:
DllDate: Mar 26 2010
Username: MyUser
filename: \\srv-phc-01\Certificados\saphety.pfx
machineKeyset: 1
localMachine: 1
exportable: 1
warningDialog: 0
Loaded the PFX file into memory...
Password verified.
Access is denied.
Failed to open Local Machine Certificate Store read/write

2) This is for sure :) The app is always running under the expected user account.

I tried a different approach to install the .pfx file and the result is the same, so it's not Chilkat's fault that its not working. I made a simple VBScript to run on users logon. I can't find any reason why it works when installed manually, and it doesn't work when installed via Chilkat or VBScript :(

Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "certutil -f -user -p ""pass"" -importpfx ""\\srv-phc-01\certificados\saphety.pfx"" NoRoot"
oShell.Run strArgs, 0, false

Answer

Thank you for your time and help. This doesn't seem like a Chilkat issue. I mean, I've tried several different methods to install the .pfx and none worked (except installing it manually as I said), so I guess it's some kind of weird voodoo nonsense going on with my ERP software. We're waiting for an answer from my software provider. Thanks again :)