Login  
Search All Forums
Dart Home | PowerTCP FTP for .NET | Custom Development Reply | PowerTCP FTP for .NET Topics | Forums   
AuthorForum: PowerTCP FTP for .NET
Topic: How to choose certificate without UI
jheller

From: horsham, PA USA
Posts: 2
Member Since: 05/14/04
posted May 14, 2004 10:01 AM

I have an automated program to connect to a known secure FTP site. I need to set the certificate for connecting to the site. The examples show how to choose a certificate using the UI, but how do I proframmatically choose it, how will I know it's the right one? What property uniqely identifies the certificate?
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted May 14, 2004 3:41 PM

Hi,
The Certificate.SerialNumber property would uniquely identify a certificate. 
But you could also check multiple properties to be sure you have the certificate you want (for example, IssuedTo and IssuerName).

CertificateStore store = new CertificateStore(CertificateStoreLocation.CurrentUser, CertificateStoreName.My);
foreach (Certificate c in store)
{
  if (c.IssuedTo == "PowerTCPTest" && c.IssuerName == "PowerTCPTest-CA")
  {
    ftp1.Certificate = c;
    break;
  }
}

Also, if you were not aware, the code for the CertificateForm that the samples use is included in the Tool (accessible from the Start menu). 
You may benefit from examining the code the form uses to display certificates.

Hope it helps,
-ken
jheller

From: horsham, PA USA
Posts: 2
Member Since: 05/14/04
posted May 17, 2004 9:27 AM

Thanks. Another question:
Since my application does not have a UI, I do not want any windows to pop up. When I try to upload a file to a secure FTP site a Dialog Box pops up, in the title is "Signing data with your private exchange key", and there is some more text in the window about requesting access to a protected item, and three buttons, OK, Cancel and Details. How do I prevent any windowws or message box from coming up?
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted May 17, 2004 9:55 AM

Hi,
If the "Enable strong private key protection" checkbox is marked when the certificate is imported into a Microsoft certificate store, the messagebox will come up whenever the certificate is used.

To prevent this, you must import it without this option checked. I would use MMC to export the certificate to a pfx file, delete the certificate from the store, and then import it again without the option checked.

Hope it helps,
-ken
Reply | PowerTCP FTP for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX