Certificate problem in Borland C++ Builder - WeOnlyDo Discussion board

Certificate problem in Borland C++ Builder (wodWebServer / wodWebServer.NET)

by paul draper, Friday, August 19, 2005, 18:02 (7035 days ago)

Hi,

I've been trying to get wodWebServer working in secure mode.

I have generated a test certificate, which I then load ie.

Cert = new TCertificate(NULL);
Cert->Load((WideString) paul.cer );
Cert->LoadKey((WideString) paul.key );

when I try to assign the certificate to the webServer object, as implied in the code snippets (in other languages):

FServer->Certificate = Cert;

I get a compilation error:

Cannot convert 'TCertificate*' to 'IDispatch*'

I tired every type of casting combination Imaginable but with no luck.

Any thoughts would be greatly appreciated.

Thanks
Paul.

Re: Certificate problem in Borland C++ Builder

by wodSupport, Friday, August 19, 2005, 18:09 (7035 days ago) @ paul draper

Paul,

I'm no BCB guru but I am 100 sure you need to cast it somehow, so look for solution. Perhaps TCertificate has DefaultInterface method, or perhaps QueryInterface? Anything like that may help.

If you're unlucky, zip your project (just make it as small as possible) and send it to techsupport email, I'll take a look and try few things. Can't be hard :)

Re: Certificate problem in Borland C++ Builder

by Paul Draper, Monday, October 03, 2005, 10:58 (6991 days ago) @ wodSupport

Hi,

I have investigated further, I've managed to load a certificate (pem format) and assign it to the Server.

[code]
Certificate1->Load((WideString) Signed Certificate.pem );
Certificate1->LoadKey((WideString) Signed Certificate.pem );

wodWebServerCom1->_set_Certificate((IDispatch*)Certificate1);
[/code]

This was the only way I was able to get the code to compile!

However I still have a problem, when I call Start() the Server is not Activated and I get an error:

14007 - The requested lookup key was not found in any active activation context.

Any ideas?

I have a small test harness that I can zip up for you if that would help.

Regards
Paul

Re: Certificate problem in Borland C++ Builder

by wodSupport, Monday, October 03, 2005, 13:37 (6991 days ago) @ Paul Draper

Paul,

Actually, not sure why, returned error is 30005. You did all correctly, but private key was not valid. How did it end up as 10047 - I have no clue.
When I opened your key, and I see it's true, you supplied SSH public key, but you need private key.
So, use GenerateKey and then Generate from Certificate object to create yourself new key.

Can you do that?

BTW, your code works ok, and conversion is ok. Perhaps instead of (ICertificate*) cast you could do [code]Certificate1->GetDefaultInterface()[/code]
seems that works nicely. It worked for me ok like this:[code]ICertificate *c = Certificate1->GetDefaultInterface();
wodWebServerCom1->_set_Certificate(c);[/code]

Re: Certificate problem in Borland C++ Builder

by Paul Draper, Tuesday, October 04, 2005, 15:56 (6990 days ago) @ wodSupport

Hi Kreso,

I generated a new certificate & key, and assigned Certificate using your sample code.

I can now Start and Connect to the Server component with no problems.

Thanks yet again for the best customer support I've ever had.

Regards
Paul.