Intermittent SSLPeerUnverifiedExceptions connecting to Confluence Cloud

We have some scripts written up in groovy which use Apache HTTP Client to perform some automated page manipulation on our Confluence Cloud instance. These had been running OK but over the last couple of months we’ve been seeing failures with: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated.

There does not seem to be a pattern to the failures; usually waiting a few minutes will let it succeed nor do we have any issue connecting to the associated JIRA cloud instance either.

So I’m a bit confused as to whats going on. The OS and JDK have both been freshly updated and so should be fully up to date with any CA changes but that wouldn’t explain the intermittent nature.

Our env:
Windows 2008R2
Oracle JDK 8 update 121
Groovy 2.4.9
apache-httpcomponents 4.2.1

NB: This was raised with Confluence Cloud support directly but was referred here; ticket was JST-289320

My guess is that you’re hitting a cloud fronting server somewhere that has an expired certificate or something else wrong with it.
I would have your code dump out the certificate data for the connection when it happens.

https://stackoverflow.com/questions/9578129/exception-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated has a couple of other suggestions.