Newsgroup: it.comp.lang.visual-basic
Titolo: Help With HTTPS connection...

Hello, I am trying to connect to an HTTPS server using the Inet Api with
this function:
Private Function PostInfo(Srv As String, Script As String, PostData As
String, conSecure As Boolean, Optional sUserName As String = "", Optional
sPassword As String = "") As String
Dim hInternetOpen As Long
Dim hInternetConnect As Long
Dim hHttpOpenRequest As Long
Dim bRet As Boolean
Dim sHeader As String
Dim lBufferLength As Long
Dim lpszPostData As String
Dim lPostDataLen As Long
Dim bDoLoop As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim sBuffer As String
Dim port As Integer
Dim Iflags
  hInternetOpen = 0
  hInternetConnect = 0
  hHttpOpenRequest = 0
  'Use registry access settings.
  hInternetOpen = InternetOpen("http generic", _
                  INTERNET_OPEN_TYPE_PRECONFIG, _
                  vbNullString, _
                  vbNullString, _
                  0)
  If hInternetOpen <> 0 Then
     'Type of service to access.
     'Change the server to your server name
  Select Case conSecure
   Case True
      port = INTERNET_DEFAULT_HTTPS_PORT
      Iflags = INTERNET_FLAG_SECURE
   Case False
      port = INTERNET_DEFAULT_HTTP_PORT
      Iflags = INTERNET_FLAG_RELOAD
  End Select
    hInternetConnect = InternetConnect(hInternetOpen, _
                       Srv, _
                       port, _
                       sUserName, _
                       sPassword, _
                       INTERNET_SERVICE_HTTP, _
                       0, _
                       0)
    If hInternetConnect <> 0 Then
      'Brings the data across the wire even if it locally cached.
      hHttpOpenRequest = HttpOpenRequest(hInternetConnect, _
                         "POST", Script, "HTTP/1.0", _
                         vbNullString, 0, Iflags, 0)
      If hHttpOpenRequest <> 0 Then
        sHeader = "Content-Type: application/x-www-form-urlencoded" _
                  & vbCrLf
        bRet = HttpAddRequestHeaders(hHttpOpenRequest, _
               sHeader, Len(sHeader), HTTP_ADDREQ_FLAG_REPLACE _
               Or HTTP_ADDREQ_FLAG_ADD)
        lpszPostData = PostData
        lPostDataLen = Len(lpszPostData)
        bRet = HttpSendRequest(hHttpOpenRequest, vbNullString, 0, _
                lpszPostData, lPostDataLen)
        sBuffer = Space(5)
        lBufferLength = Len(sBuffer)
        bRet = HttpQueryInfo(hHttpOpenRequest, HTTP_QUERY_STATUS_CODE, ByVal
sBuffer, lBufferLength, 0)
        m_ErrNumber = Val(Left(sBuffer, lBufferLength))
        If m_ErrNumber <> 200 Then
          sBuffer = Space(500)
          lBufferLength = Len(sBuffer)
          bRet = HttpQueryInfo(hHttpOpenRequest, HTTP_QUERY_STATUS_TEXT,
ByVal sBuffer, lBufferLength, 0)
          m_ErrDescription = Left(sBuffer, lBufferLength)
        Else
          m_ErrNumber = 0
        End If
        sBuffer = ""
        bDoLoop = True
        While bDoLoop
          sReadBuffer = vbNullString
          bDoLoop = InternetReadFile(hHttpOpenRequest, _
                                     sReadBuffer, _
                                     Len(sReadBuffer), _
                                     lNumberOfBytesRead)
          sBuffer = sBuffer & Left(sReadBuffer, lNumberOfBytesRead)
          If Not CBool(lNumberOfBytesRead) Then
            bDoLoop = False
          Else
            DoEvents
            Sleep 100
          End If
        Wend
        PostInfo = sBuffer
        bRet = InternetCloseHandle(hHttpOpenRequest)
      End If
      bRet = InternetCloseHandle(hInternetConnect)
    End If
    bRet = InternetCloseHandle(hInternetOpen)
  End If
End Function
But when I connect to an https ASP page the Request.ServerVariables("HTTPS")
returns me off.
 so ... what is wrong ?
Please help And replay to 
z...@inter.net.il
 Thanks.....
 Thanks in advance
 -ziv

