# SSL certificate debugging

**URL:** https://discuss.python.org/t/ssl-certificate-debugging/19883
**Category:** Ideas
**Created:** [October 11, 2022, 12:33pm UTC](https://discuss.python.org/t/ssl-certificate-debugging/19883 "2022-10-11T12:33:34Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![petersuter](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@petersuter](https://discuss.python.org/u/petersuter)
#### Post date: [October 11, 2022, 4:13pm UTC](https://discuss.python.org/t/ssl-certificate-debugging/19883/4 "2022-10-11T16:13:50Z")

</div>

> The reason for the rejection is right there in the exception message: the certificate has expired.

That’s not correct though. Or incomplete: Which certificate? Maybe (one of) the intermediate certificates was.

> Do you have to use Python to inspect the certificate?

Python is the only software that has a problem with the certificate. So it would be nice to confirm which one Python “sees”.

> Do you have a concrete suggestion for how this could be improved?

Maybe improve / fix the error message? (See also [this discussion](https://discuss.python.org/t/improve-error-message-for-ssl-certificate-verify-failed-error/19479/2)?)

Maybe allow access to the certificate if verification fails, maybe via an exception attribute?  
Maybe allow access to the certificate if verification is disabled? (`getpeercert()` returns `{}`.)

Maybe allow logging more useful information or registering a callback to inspect the certificate?

(And inspecting the relevant chain.)

Maybe look at [Mercurial’s debugssl command](https://www.mercurial-scm.org/repo/hg/file/tip/mercurial/debugcommands.py#l3909)?

---

_[View the full topic](https://discuss.python.org/t/ssl-certificate-debugging/19883)._
