NetTalk Central

Author Topic: SOAP with SSL  (Read 13629 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1846
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
SOAP with SSL
« on: July 13, 2010, 08:04:19 AM »
Hi,
I need to send a SOAP req to a SSL server.
I`ve modfied the SOAP example to do it but I need help
Which code must I use to do it?
I`using;

   PostString = |
   '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> '&|
   '<SOAP-ENV:Header> '&|
   '<t:Transaction xmlns:t="xxs"> '&|
   '<tc> '&|
   '<iden u="devuser"/><provider session="WXMLPROD">Worldspan</provider> '&|
   '</tc> '&|
   '</t:Transaction> '&|
   '</SOAP-ENV:Header> '&|
   '<SOAP-ENV:Body> '&|
   '<ns1:ProviderTransaction xmlns:ns1="xxs"> '&|
   '<REQ> '&|
   ''&|
   '<TTC><MSG>This is a test</MSG></TTC> '&|
   ''&|
   '</REQ> '&|
   '</ns1:ProviderTransaction> '&|
   '</SOAP-ENV:Body> '&|
   '</SOAP-ENV:Envelope> '&|
   ''

  PostURL = 'http://xmlpropp.worldspan.com:443'

  ThisWebClient.SetAllHeadersDefault()
  ThisWebClient.Pragma_ = 'No-Cache'     ! Force any proxies to not use their cache. Uses more bandwidth but will contact the webserver directly which is what we want.
  ThisWebClient.CacheControl = 'No-Cache'! Force any proxies to not use their cache. Uses more bandwidth but will contact the webserver directly which is what we want.
  ThisWebClient.ContentType = 'text/xml'
  ThisWebClient.AcceptEncoding = ''
  ThisWebClient.ContentLength = len (clip(PostString))
  ThisWebClient.AsyncOpenTimeOut = 1200       ! 12 seconds
  ThisWebClient.InActiveTimeout  = 2000        ! 20 seconds
   
  ThisWebClient.SSL = 1 ! Use SSL to make a Secure Web Server
  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateCommonName = 1
  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateWithCARoot = 1
!  ThisWebClient.SSLCertificateOptions.CertificateFile = clip('web\') & clip('certificates\' & Clip(Glo:CertificateName)) & '.crt'
!message(clip('web') & '\' & clip('certificates\' & Clip(Glo:CertificateName)) & '.crt')
!  ThisWebClient.SSLCertificateOptions.PrivateKeyFile =  clip('web\') & clip('certificates\' & Clip(Glo:CertificateName)) & '.key'   
   
  ThisWebClient.Post(PostURL,PostString)


But I`m allways getting a timeout
Any help please!
Thanks
Alberto

PD: attached goes the client.app



[attachment deleted by admin]
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: SOAP with SSL
« Reply #1 on: July 13, 2010, 10:28:09 PM »
At a guess all you need to do is set

  PostURL = 'https://xmlpropp.worldspan.com:443'

note the https instead of http.

Cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1846
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: SOAP with SSL
« Reply #2 on: July 14, 2010, 03:32:33 AM »
Thanks Bruce,

Its weird, the program only works if Fiddler is running!!!!
If I shut down fiddler I always get a time-out error.

I´ve copied the exe to another computer in the same network (W7) and I get an inmediate "Unable to Open Connection" error

Attached goes the app and exe

Any idea?
Thanks
Alberto

[attachment deleted by admin]
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1846
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: SOAP with SSL
« Reply #3 on: July 14, 2010, 06:08:49 AM »
Here is the problem,

Fiddler2 includes the ability to decrypt, view, and modify HTTPS-secured traffic for debugging purposes.  This feature is disabled by default.
Enable this option by clicking Tools > Fiddler Options > HTTPS and ticking the "Decrypt HTTPS Traffic" box.

When you tick this option fiddler installs a certificate with which it decripts the secure trafic.

I could export this certificate to my desktop and installed it outside fiddler but the app continues failing withot fiddler running.

Where do I set wich certificate to use to decript the secure traffic inside the app?

I´ve tried out all combinations of:
  ThisWebClient.SSLCertificateOptions.CertificateFile = '' !'.\Certificate.crt' !clip('web\') & clip('certificates\' & Clip(Glo:CertificateName)) & '.crt'
  ThisWebClient.SSLCertificateOptions.PrivateKeyFile  = '' !'.\Certificate.key' ! clip('web\') & clip('certificates\' & Clip(Glo:CertificateName)) & '.key'   
  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateCommonName = 0
  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateWithCARoot = 0
  ThisWebClient.SSLCertificateOptions.CARootFile = '.\CaRoots.pem'

Using the Certificate.crt, key and CaRoot.pem of the examples and nothing.
If I Use Caroot the error is "SSL failed to load the CA root file"


Please HELP!!!

THanks
Alberto
« Last Edit: July 14, 2010, 07:17:40 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: SOAP with SSL
« Reply #4 on: July 15, 2010, 12:08:51 PM »
try
  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateCommonName = 1
  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateWithCARoot = 1
  ThisWebClient.SSLCertificateOptions.CARootFile = '.\CaRoots.pem'

Also - have you copied caroots.pem to the application folder?

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1846
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: SOAP with SSL
« Reply #5 on: July 19, 2010, 05:29:58 AM »
Bruce,
This is exactly what I´m doing but it always times out!
Please, try the app attached.
The code is in the SendTest procedure routine.
You only need to compile it and press the Test button.
With fiddler running it works ok, withot it timesout.
Please, please, I will loose the contract!
Thanks
Alberto

[attachment deleted by admin]
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: SOAP with SSL
« Reply #6 on: July 19, 2010, 08:39:06 AM »
Hi Alberto,

Unfortunately your example is using iqXML, which I don't have installed on my Clarion 7.
So I've gone back to your first example.

At the moment the https://xmlpropp.worldspan.com/ site appears to be down. I'll try again later.

cheers
Bruce


Alberto

  • Hero Member
  • *****
  • Posts: 1846
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: SOAP with SSL
« Reply #7 on: July 19, 2010, 08:46:47 AM »
Bruce,
Weird, Its up for me now.
You can use the last app, its the same problem.
Thanks
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: SOAP with SSL
« Reply #8 on: July 19, 2010, 09:23:01 AM »
>> Its weird, the program only works if Fiddler is running!!!!
>> If I shut down fiddler I always get a time-out error.

yes I get the same running it from here.
What's happening is that the server is not closing the connection - so pageReceived is not being triggered. It should triiger on the content-length (which I'll investigate).

In the meantime you should ad the following line after SetAllHeadersDefault;

  ThisWebClient.SetAllHeadersDefault()
  ThisWebClient.ConnectionKeepAlive = 0


>> I´ve copied the exe to another computer in the same network (W7) and I get an inmediate "Unable to Open Connection" error

you didn't copy the necessary SSL DLL's

Cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1846
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: SOAP with SSL
« Reply #9 on: July 19, 2010, 10:41:38 AM »
Ok Bruce, its working.

You say I need to have the SSL DLLs, but I dont understand how does it work?
The dlls are not in my project, who is using this dlls?

Thanks
Alberto
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: SOAP with SSL
« Reply #10 on: July 19, 2010, 09:05:45 PM »
The SSL Dll's are loaded by the NetTalk DLL at runtime, if they are required. They do not get linked into your project.

see http://www.capesoft.com/docs/NetTalk/NetTalk.htm#SSL_DLL_Distribution

Cheers
Bruce