Nov
11
Posted (Johan Känngård) in LotusScript, Visual Basic, Windows on 2005-11-11

I have tried to search for the literal values of some of the options to WinHTTP that handles SSL server certificates errors. In my case I have a development server that has a certificate with the wrong name in it, and I want to ignore the usual “The host name in the certificate is invalid or does not match” error. Since I am using LotusScript to access the COM class WinHTTP.WinHTTPRequest, I can’t simply use:

Dim http As Variant
Set http = CreateObject("WinHTTP.WinHTTPRequest.5.1")
http.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = 13056

This of course generates an error, since the WinHttpRequestOption_SslErrorIgnoreFlags constant can not be found in LotusScript.
The answer couldn’t be found anywhere on MSDN, but some searching on Google led me to a page at fastbugtrack.com with some code that contains the constant I needed! So here they are for future reference:

' WinHTTPRequest options:
Const WinHttpRequestOption_UserAgentString = 0
Const WinHttpRequestOption_URL = 1
Const WinHttpRequestOption_URLCodePage = 2
Const WinHttpRequestOption_EscapePercentInURL = 3
Const WinHttpRequestOption_SslErrorIgnoreFlags = 4
Const WinHttpRequestOption_SelectCertificate = 5
Const WinHttpRequestOption_EnableRedirects = 6
Const WinHttpRequestOption_UrlEscapeDisable = 7
Const WinHttpRequestOption_UrlEscapeDisableQuery = 8
Const WinHttpRequestOption_SecureProtocols = 9
Const WinHttpRequestOption_EnableTracing = 10

The actual value for http.Option(WinHttpRequestOption_SslErrorIgnoreFlags) that I have set to 13056 (hexadecimal 0×3300) is an addition of all switches found at the WinHttpRequestOption documentation at WinHttpRequestOption_SslErrorIgnoreFlags.


Comments:
Andrei Kouvchinnikov on January 23rd, 2006 at 14:42:51 #

I usually use Visual Basic (or Excel) to find out the value of unknown variables.

You simply add “Microsoft WinHTTP Services” reference to your VB project, and then show the value using messagebox:

MsgBox (WinHttpRequestOption_SslErrorIgnoreFlags)

Johan Känngård on January 23rd, 2006 at 15:04:16 #

That’s useful if you are using Microsoft’s IDE’s. Too bad it’s not working when using Lotus Domino Designer and LotusScript. In the Designer, I only have access to the ActiveX-classes, and not the constants. But your tip is a good one anyway!

adam on October 22nd, 2007 at 16:17:00 #

Have you got any lotusscript that sets the username and password using this code?

Johan Känngård on October 22nd, 2007 at 16:36:03 #

You can add the username and password in the URL, as described by Chris at http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/d6plinks/DOMO-6LRC7H

Post a comment
Name: 
Email: 
URL: 
Comments: