Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Bob Swart (aka Drs.Bob) Dr.Bob's Delphi Clinics Dr.Bob's Delphi Courseware Manuals
View Bob Swart's profile on LinkedIn Drs.Bob's Delphi Notes
These are the voyages using Delphi Enterprise (and Architect). Its mission: to explore strange, new worlds. To design and build new applications. To boldly go...

WSE 2.0 X509CertificateStore constants in Delphi 2005

Author: Bob Swart
Posted: 10/31/2005 2:10:13 PM (GMT+1)

The December issue of The Delphi Magazine will contain an article about my experiences with extending SOAP and Web Services with security options like authentication and encryption. In the article, I'm using both SOAP Headers, RSA Encryption and X509 certificates, using mainly ASP.NET but also showing Win32 examples.

As usual, the article is based on real-world experiences, and one of the little issues I've encountered with Delphi 2005 is the use of Web Service Enhancements version 2.0 for ASP.NET Web Services. Specifically, the WSE 2.0 X509CertificateStore constants for MyStore, OtherPeople (aka AddressBook), etc.

I'm not going to mention the fact that Windows 2003 doesn't always offer an OtherPeople store for certificates - read the fine magazine for tips on that issue.

What I can't allow to go unnoticed - and have reported to Quality Central as #20484 - is the following: When using WSE 2.0 with Delphi for .NET, you can use the X509CertificateStore class to open a x509 certificate store. There are a number of predefined store names, which can be access through constants, namely:

X509CertificateStore.MyStore // My
X509CertificateStore.CAStore // CA
X509CertificateStore.RootStore // Root
X509CertificateStore.TrustStore // Trust
X509CertificateStore.OtherPeople // AddressBook

However, the value of these constants are cut in half using Delphi 2005. Instead of string values like "My" and "CA", I get only "M", "C", "Ro", "Tr", "Addre", and "Disal". The cut is exactly in half, so it may be a Wide/Ansi/Unicode string issue?

Anyway, when my code didn't work (the X509CertificateStore.MyStore certificate store refused to be opened), it took me a little while to figure out that all other source lines were correct (and so were the deployed certificates with the public key imported in the CurrentUser's Personal as well as OtherPeople store, and the public/private key combination imported in the Server's LocalMachine Personal store).

Since this took me a little while to figure out, it may save you some time if you're in the same situation. Of course, there's a good chance it will be fixed in DeXter ;-)



miguel06/01/28 18:22:49very good
Adolfo 09/06/23 19:04:55 Hi thanks for the article has been very useful for me. I have a big problem and would like to know if you help me find out trying to invoke a WS https: / / / ISarahWS.asmx and a problem with certificate I am using delphi and I have a problem that says: "Project.exe raised exception class ESOAPHTTPException with message "The Certificate authority is invalid or incorrect - URL:" I talk to the people own the WS and report problems that delphi 2005 license must think this is true? would greatly appreciate your support because I have a thousand rounds in internet and I have not anything to solve this problem, PLEASE.
Bob Swart 09/06/24 10:22:34Is this a X509 certificate you have problems with? Have you tried Delphi 2007?
Mark 11/06/22 11:41:29Is this article still available anywhere. I am struggling at the moment with a Delphi application in which I need to encrypt some data using the RSA Encryption and a public key certificate that I have been provided with and this article looks like it would cover everything I need to know. thanks
Bob Swart 11/06/22 22:37:06The original article used Delphi 2005 for .NET, and I also cover this with RAD Studio 2007 for .NET in a RAD Studio 2007 XML, SOAP and Web Services courseware manual which is no longer for sale (because the .NET part of RAD Studio 2007 is also no longer available). If you plan to use Delphi Prism, then the solution is different anyway. If you plan to use Delphi 2005 for .NET or RAD Studio 2007 for .NET, then I will have the article for you (a reprint from The Delphi Magazine issue #124. See for the example source code...

New Comment (max. 2048 characters, no HTML):


This webpage © 2005-2014 by Bob Swart (aka Dr.Bob - All Rights Reserved.