How to handle SSL connection errors using OnAfterResponse?

I'm looping over list of URL's and pinging each of them to check if the site is alive or not. However, Loop start to break when it find sites with Expired SSL certifications. 

So far, I tried AllExpections and If Statements on OnAfterResponse, but none of them working. 

I still get the same exception on response. 

"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel"


Any suggestions to tackle this issue?

Hi Daniel,

I think you cannot handle this SSL error in the OnAfterResponse action as it will be to late.

This error occurs during the SSL handshake procedure, which happens before the actual request is made. This SSL handshake between the client and server needs to be successful in order to establish a secure connection. Only after this secure connection is established, the actual web request to that specific site is allowed to happen.

I hope this helps.

Regards,

Nordin


Can you explain a little more on how you have implemented this Daniel? Maybe you can share an example.

In the meantime, I’m going to think some more about this.

Regards,

Nordin

Solution

Hi Daniel, 

To avoid an Exception that breaks the For Each, encapsulate the "ping" in an Action of its own, and add an Exception Handler to that Action. Since it's handled there, out won't percolate up, so the For Each continues.

Solution

Kilian Hekhuis wrote:

Hi Daniel, 

To avoid an Exception that breaks the For Each, encapsulate the "ping" in an Action of its own, and add an Exception Handler to that Action. Since it's handled there, out won't percolate up, so the For Each continues.


Clever idea. It's works. Thank you!

Thanks for clearing up the issue Kilian :).

I’m sure you’ve done this already Daniel, since you’ve solved your issue already. Just to clarify, the Abort Transaction of the Exception Handler inside the action needs to be set to ‘No’ in order for the Loop to continue. Otherwise it would still break the For Each.

Regards,

Nordin

Hi Nordin, that is not quite true. "Abort transaction" only concerns database transactions, so setting it to Yes does not affect the For Each. However, if Daniel stores the result of the ping in the database, it should indeed be set to No, to avoid a rollback and losing the stored data up to that point, unless of course a Commit is given after each store.



You’re right Kilian. Abort Transaction only concerns database transactions. I assumed he stores some value in the database in order to keep track of the ping requests.

Thank you for the rectification.