Jump to content

handling (Click)certificate issues


Nirmal
 Share

Recommended Posts

    • Everything went through except clicking the certificate link "continue to this website (not recommended)"

      I've tried with both _IELinkClickByText($oIE, "Continue to this website (not recommended).",0,0) and _IEAction($oLink,"click") options.. but no success. ( Win2016 - IE 11)

      $oIE= _IECreate("https://10.208.**.**/xxx")

      Sleep(1000)

        ; _IENavigate($oIE, "https://10.208.**.**/xxx")

        Sleep(500)

      ; -----------------

      ; Handle login here! ; CHANGE_ME

      ; ------------------

      WinWaitActive("Certificate Error: Navigation Blocked - Internet Explorer")

      ; Check if there is a certificate Error

      if (IsCertificateErrorPage($oIE)) Then

      _IELinkClickByText($oIE, "Continue to this website (not recommended).",0,0)

      ContinueOnCertificateError($oIE)

      EndIf

       ToolTip("before clientPID 4")

        $ConnectionClientPID = WinGetProcess("[CLASS:IEFrame]")

        if ($ConnectionClientPID == 0) Then

        Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))

        EndIf


         ; Send PID to PSM as early as possible so recording/monitoring can begin

        LogWrite("sending PID to PSM")

        if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then

          Error(PSMGenericClient_PSMGetLastErrorString())

        EndIf


       LogWrite("sending PID to PSM Nirmal")

        if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then


       Error(PSMGenericClient_PSMGetLastErrorString())

       EndIf

       LogWrite("Terminating Dispatcher Utils Wrapper")

       PSMGenericClient_Term()


       Return $PSM_ERROR_SUCCESS

       EndFunc

       
       ; #FUNCTION# ====================================================================================================================

      ; Name...........: IsCertificateErrorPage


      ; Description ...: This function checks If the IE object is on a website security certificate error page.

      ; Parameters ....: $IEObject - the IE instance to check

      ; Return values .: True If on certification error page, False otherwise


      ; ===============================================================================================================================
       

      Func IsCertificateErrorPage($oIE1)

      local $returnVal = FALSE

      local $str="There is a problem with this website's security certificate."

      local $str="security certificate."

      local $ieStr=_IEBodyReadText($oIE1)

      LogWrite(_IEBodyReadText($oIE1))

      LogWrite(StringInStr($ieStr,$str)) 

      if (StringInStr($ieStr,$str) > 1) Then

      LogWrite("Nirmal - There is a problem with this website's security certificate")

      $returnVal = True

       

      EndIf

      LogWrite("Nirmal ======================= FALSE")

      return $returnVal


      EndFunc

       

      ; #FUNCTION# ====================================================================================================================


      ; Name...........: ContinueOnCertificationError


      ; Description ...: This function clicks on "continue to this website (not recommended)" link on certification error page.

      ; Parameters ....: $IEObject - the IE instance


      ; Return values .: none


      ; ===============================================================================================================================

       
      Func ContinueOnCertificateError($oIE)

      local $oLinks = _IELinkGetCollection($oIE)

      For $oLink In $oLinks

        If String($oLink.innerText) = "Continue to this website (not recommended)." Then

          ; MsgBox(0, "Link", $oLink.innerText & " - " & $oLink.href)

      ; _IELinkClickByText($oIE, "Continue to this website (not recommended).",0,0)

      _IEAction($oLink,"click")

      _IELinkClickByText($oIE,$oLink.innerText)

      LogWrite($oLink.innerText) 

      ExitLoop

        EndIf

      Next


      EndFunc

      ===============

      LOG details

      [18/02/2019 | 17:31:09] | :: | PSMDU019I Dispatcher trace message: [QMC Dispatcher - 

       There is a problem with this website’s security certificate.

       The security certificate presented by this website was issued for a different website's address.

       Security certificate problems may indicate an attempt to fool you or intercept any data you send to the server. 

       We recommend that you close this webpage and do not continue to this website. 

       Click here to close this webpage. 

       Continue to this website (not recommended). 

       More information 

       If you arrived at this page by clicking a link, check the website address in the address bar to be sure that it is the add

      [18/02/2019 | 17:31:09] | :: | ress you were expecting.

       When going to a website with an address such as https://example.com, try adding the 'www' to the address, https://www.example.com.

       For more information, see "Certificate Errors" in Internet Explorer Help.]

      [18/02/2019 | 17:31:09] | :: | PSMDU019I Dispatcher trace message: [QMC Dispatcher - 46]

      [18/02/2019 | 17:31:09] | :: | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Nirmal - There is a problem with this website's security certificate]

      [18/02/2019 | 17:31:09] | :: | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Nirmal ======================= FALSE]

      [18/02/2019 | 17:31:09] | :: | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Continue to this website (not recommended).]

      LikeReplySelect as Best
       

Link to comment
Share on other sites

Link to comment
Share on other sites

@NineHere is my code: Please let me know if you any more details ... (Win 2016).. thanks 

#AutoIt3Wrapper_UseX64=n

Opt("MustDeclareVars", 1)

AutoItSetOption("WinTitleMatchMode", 3) ; EXACT_MATCH!

;============================================================
; Created : December 2018

; Nirmal Dhanaraj

; Sailpoint IdentityNow Web Portal
;============================================================

#include <PSMGenericClientWrapper.au3>

#include <GuiMenu.au3>
#include <IE.au3>
#include <Inet.au3>


Global Const $DISPATCHER_NAME     = "QQC" ; CHANGE_ME - Nirmal

Global Const $CLIENT_EXECUTABLE = "C:\Program Files\internet explorer\iexplore.exe" ; CHANGE_ME - Nirmal

Global Const $ERROR_MESSAGE_TITLE   = "PSM " & $DISPATCHER_NAME & " Dispatcher error message"

Global Const $LOG_MESSAGE_PREFIX = $DISPATCHER_NAME & " Dispatcher - "


Global $TargetUsername

Global $TargetPassword

Global $TargetAddress

Global $TargetPort

Global $ConnectionClientPID = 0

Global $oIE

Global $handle, $hWnd

;=======================================
; Code
;=======================================

Exit Main()

;=======================================
; Main
;=======================================

Func Main()


;Init PSM Dispatcher utils wrapper

      ToolTip ("Initializing...")

      if (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then

      Error(PSMGenericClient_PSMGetLastErrorString())

      EndIf

      LogWrite("successfully initialized Dispatcher Utils Wrapper - QQC Portal")


;Get the dispatcher parameters

      FetchSessionProperties()

      LogWrite("mapping local drives - IdentityNow")

      if (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then

      Error(PSMGenericClient_PSMGetLastErrorString())

      EndIf


      LogWrite("starting client application")

      ToolTip ("Starting " & $DISPATCHER_NAME & "...")


    LogWrite("starting client application")
    ToolTip ("Starting " & $DISPATCHER_NAME & "...")
    
    $oIE= _IECreate()
    Sleep(1000)

    _IENavigate($oIE, "https://10.208.46.2**/QQC")
    Sleep(3000)
    

; ------------------

; Handle login here! ; CHANGE_ME
; ------------------
;WinWaitActive("Certificate Error: Navigation Blocked - Internet Explorer")
; Check if there is a certificate Error

if (IsCertificateErrorPage($oIE)) Then

ContinueOnCertificateError($oIE)
EndIf


    $ConnectionClientPID = WinGetProcess("[CLASS:IEFrame]")
    if ($ConnectionClientPID == 0) Then
    Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))
    EndIf

     ; Send PID to PSM as early as possible so recording/monitoring can begin
    LogWrite("sending PID to PSM")
    if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then
        Error(PSMGenericClient_PSMGetLastErrorString())
    EndIf


; Send PID to PSM as early as possible so recording/monitoring can begin  MsgBox(64, 'Button Found', 'Button found with value: ' & $oButton.value)
      LogWrite("sending PID to PSM Nirmal")

      if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then

      Error(PSMGenericClient_PSMGetLastErrorString())

      EndIf

      LogWrite("Terminating Dispatcher Utils Wrapper")

      PSMGenericClient_Term()


      Return $PSM_ERROR_SUCCESS

      EndFunc

  ; #FUNCTION# ====================================================================================================================

; Name...........: IsCertificateErrorPage

; Description ...: This function checks If the IE object is on a website security certificate error page.

; Parameters ....: $IEObject - the IE instance to check

; Return values .: True If on certification error page, False otherwise

; ===============================================================================================================================

Func IsCertificateErrorPage($oIE1)
local $returnVal = FALSE
local $str="There is a problem with this website's security certificate."
local $str="security certificate."
local $ieStr=_IEBodyReadText($oIE1)
 LogWrite(_IEBodyReadText($oIE1))
if (StringInStr($ieStr,$str) > 1) Then
                                    
 LogWrite("Nirmal - There is a problem with this website's security certificate")
$returnVal = True

EndIf
LogWrite("Nirmal ======================= FALSE")
return $returnVal

EndFunc

 

; #FUNCTION# ====================================================================================================================

; Name...........: ContinueOnCertificationError

; Description ...: This function clicks on "continue to this website (not recommended)" link on certification error page.

; Parameters ....: $IEObject - the IE instance

; Return values .: none

; ===============================================================================================================================

Func ContinueOnCertificateError($oIE)
 LogWrite($oLink.outerText) 
   If String($oLink.outerText) = "Continue to this website (not recommended)."  Then
        ; MsgBox(0, "Link", $oLink.outerText & " - " & $oLink.href)
        _IELinkClickByText($oIE, "Continue to this website (not recommended).")
        _IEAction($oLink,"click")
         _IELinkClickByText($oIE,$oLink.outerText)
        LogWrite($oLink.outerText) 
         ExitLoop
    EndIf
Next

EndFunc

; #FUNCTION# ====================================================================================================================

; Name...........: Error

; Description ...: An exception handler - displays an error message and terminates the dispatcher

; Parameters ....: $ErrorMessage - Error message to display

;   $Code - [Optional] Exit error code

; ===============================================================================================================================

   Func Error($ErrorMessage, $Code = -1)

; If the dispatcher utils DLL was already initialized, write an error log message and terminate the wrapper

   if (PSMGenericClient_IsInitialized()) Then

   LogWrite($ErrorMessage, True)

   PSMGenericClient_Term()

   EndIf


   Local $MessageFlags = BitOr(0, 16, 262144) ; 0=OK button, 16=Stop-sign icon, 262144=MsgBox has top-most attribute set

   MsgBox($MessageFlags, $ERROR_MESSAGE_TITLE, $ErrorMessage)

   ;If the connection component was already invoked, terminate it

   if ($ConnectionClientPID <> 0) Then

   ProcessClose($ConnectionClientPID)

   $ConnectionClientPID = 0

   EndIf

   Exit $Code

   EndFunc
 

; #FUNCTION# ====================================================================================================================

; Name...........: LogWrite

; Description ...: Write a PSMWinSCPDispatcher log message to standard PSM log file

; Parameters ....: $sMessage - [IN] The message to write

; $LogLevel - [Optional] [IN] Defined if the message should be handled as an error message or as a trace messge

; Return values .: $PSM_ERROR_SUCCESS - Success, otherwise error - Use PSMGenericClient_PSMGetLastErrorString for details.

; ===============================================================================================================================

   Func LogWrite($sMessage, $LogLevel = $LOG_LEVEL_TRACE)

   Return PSMGenericClient_LogWrite($LOG_MESSAGE_PREFIX & $sMessage, $LogLevel)

   EndFunc


; #FUNCTION# ====================================================================================================================

; Name...........: PSMGenericClient_GetSessionProperty

; Description ...: Fetches properties required for the session

; Parameters ....: None

; Return values .: None

; ===============================================================================================================================

   Func FetchSessionProperties() ; CHANGE_ME

   if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then

   Error(PSMGenericClient_PSMGetLastErrorString())

   EndIf


if (PSMGenericClient_GetSessionProperty("Password", $TargetPassword) <> $PSM_ERROR_SUCCESS) Then

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf


EndFunc

 

DOM.txt

Link to comment
Share on other sites

@Nirmal, if what you are automating is an internal web application (as i presume from the address), then easier method would be to configure IE to disable warning about certificate mismatch.

if the browser is used by regular users, of course disregard that advice.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Func ContinueOnCertificateError($oIE)
 LogWrite($oLink.outerText) 
   If String($oLink.outerText) = "Continue to this website (not recommended)."  Then
        ; MsgBox(0, "Link", $oLink.outerText & " - " & $oLink.href)
        _IELinkClickByText($oIE, "Continue to this website (not recommended).")
        _IEAction($oLink,"click")
         _IELinkClickByText($oIE,$oLink.outerText)
        LogWrite($oLink.outerText) 
         ExitLoop
    EndIf
Next

EndFunc

Your function is broken.  Repair it and put a LOT of messages (errors and contents) around.  I would like to see those because I do not understand what is wrong so far

Link to comment
Share on other sites

@NineAs per your advise I've modified the script and tested. The Click event (Continue to this website (not recommended).) is not happening. I've attached log as well. Please advise .. thanks 

Func IsCertificateErrorPage($oIE)
local $returnVal = FALSE
local $str="There is a problem with this website's security certificate."
local $str="security certificate."
local $ieStr=_IEBodyReadText($oIE)
 LogWrite(_IEBodyReadText($oIE))
 LogWrite(StringInStr($ieStr,$str)) 
if (StringInStr($ieStr,$str) > 1) Then
                                
$returnVal = True

EndIf
LogWrite("Return Value is : ")
LogWrite($returnVal)
return $returnVal

EndFunc

; #FUNCTION# ====================================================================================================================

; Name...........: ContinueOnCertificationError

; ===============================================================================================================================

Func ContinueOnCertificateError($oIE)
  LogWrite("ContinueOnCertificateError()")
local $oLinks = _IELinkGetCollection($oIE)

For $oLink In $oLinks
    LogWrite($oLink.outerText)
   If String($oLink.outerText) = "Continue to this website (not recommended)."  Then
      LogWrite("Inside IF Con") 
      LogWrite($oLink.outerText)
        _IELinkClickByText($oIE, "Continue to this website (not recommended).")
    ;   _IEAction($oLink,"click")
         
    ExitLoop
    EndIf
Next

EndFunc

Log is as follows :

[20/02/2019 | 07:07:23] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - starting client application]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher -    There is a problem with this website’s security certificate.                      The security certificate presented by this website was issued for a different website's address.          Security certificate problems may indicate an attempt to fool you or intercept any data you send to the server.    We recommend that you close this webpage and do not continue to this website.      Click here to close this webpage.      Continue to this website (not recommended).        More information        If you arrived at this page by clicking a link, check the website address in the address bar to be sure that it is the add
[20/02/2019 | 07:07:29] |  ::  | ress you were expecting.  When going to a website with an address such as https://example.com, try adding the 'www' to the address, https://www.example.com.      For more information, see "Certificate Errors" in Internet Explorer Help.]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - 46]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Return Value is : ]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - True]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - ContinueOnCertificateError()]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Click here to close this webpage.]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Continue to this website (not recommended).]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Inside IF Con]
[20/02/2019 | 07:07:29] |  ::  | PSMDU019I Dispatcher trace message: [QMC Dispatcher - Continue to this website (not recommended).]

PSMGenericClientDriver.log.2019-02-20__07-24-33.log

Link to comment
Share on other sites

Have you tried to use $oLink.click ().  Otherwise I don't know, you have the right object for sure...

You could try to simply close the window or kill it.

Edited by Nine
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...