Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.3k views
in .NET FTP by (360 points)
The following code works correctly w/in a Windows .NET Form Application

SSLFTPCertificate clientCertificate = SSLFTPCertificate.CreateFromCER(certFileName);
clientCertificate.AssociatePrivateKey(prvKeyFileName, password);

However, in a Windows .NET Service, running as the same user and with the same filename/password/etc, gets the following Exception.

Org.Mentalis.Security.Certificates.CertificateException: Could not import the private key from the PVK file (s1hCg7vIb)
at oDxWX6UrVopxSDInbkS.TBRxOaUlH8guapN2NIa.sWNYYZ71sS(String , String , Boolean )
at oDxWX6UrVopxSDInbkS.TBRxOaUlH8guapN2NIa.RZjY1XWKoW(String , String )
at EnterpriseDT.Net.Ftp.Ssl.SSLFTPCertificate.AssociatePrivateKey(String pvkFileName, String password)
at CdrProcessing.EdtFtpClient.LoadClientCertificate() in C:\TMCApps\CdrProcessing\code\CdrProcessing\EdtFtpClient.cs:line 116
[Where the last line is the invocation of the AssociatedPrivateKey above]

Any help would be greatly appreciated.

Thanks,

James Smyth

2 Answers

0 votes
by (162k points)
This is almost certainly a permissions problem - you may need to run as the local system user for the service.
0 votes
by (360 points)
Yep, it was apparently some kind of security issue. I spent a lot of time trying to figure out what local/security policy was involved but ended up running the service as the local SERVICE user and impersonating another user as necessary.

Categories

...