File: n_winhttpex.sru
Size: 2157
Date: Thu, 12 Mar 2020 02:56:24 +0100
$PBExportHeader$n_winhttpex.sru
$PBExportComments$WinHTTP descendant
forward
global type n_winhttpex from n_winhttp
end type
end forward

global type n_winhttpex from n_winhttp
end type

type variables
Boolean ib_Cert_allowSelfSigned, ib_Cert_allowExpired

end variables

forward prototypes
protected function boolean of_sendrequesterror (ref boolean ab_retry)
end prototypes

protected function boolean of_sendrequesterror (ref boolean ab_retry);// ------------------------------------------------------------------------------------------------------
// SCRIPT:     SendRequestError (Override)
//
// PURPOSE:    Allow developer to specify that self-signed or expired
//             certificates are ok.
//
//    SECURITY_FLAG_IGNORE_UNKNOWN_CA        Allows an invalid certificate authority. 
//    SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE  Allows the identity of a server to be established with a
//                                           non-server certificate (for example, a client certificate).
//    SECURITY_FLAG_IGNORE_CERT_CN_INVALID   Allows an invalid common name in a certificate; that is,
//                                           the server name specified by the application does not
//                                           match the common name in the certificate
//    SECURITY_FLAG_IGNORE_CERT_DATE_INVALID Allows an invalid certificate date, that is, an expired or
//                                           not-yet-effective certificate
// ------------------------------------------------------------------------------------------------------

Boolean lb_HardError
ULong lul_flags

choose case LastErrorNum
   case ERROR_WINHTTP_SECURE_FAILURE
      If ib_Cert_allowSelfSigned Then
         lul_flags += SECURITY_FLAG_IGNORE_UNKNOWN_CA
      End If

      If ib_Cert_allowExpired Then
         lul_flags += SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
      End If

      If lul_flags > 0 Then
         If SetRequestOption(WINHTTP_OPTION_SECURITY_FLAGS, lul_flags) Then
            ab_Retry = True
         End If
      End If
   case ERROR_WINHTTP_RESEND_REQUEST
      ab_Retry = True
   case else
      lb_HardError = True
end choose

Return lb_HardError

end function

on n_winhttpex.create
call super::create
end on

on n_winhttpex.destroy
call super::destroy
end on