I need to get an expiration date of a ssl certificate on a site using selenium. Is there some way to do that? I know that there is selenium errors that is triggered if ssl certificate is expired, but how can I get info about date of expiration if it's still valid?
Asked
Active
Viewed 185 times
1 Answers
0
It is probably impossible to get these information using selenium since it is impossible to get these information from inside the browser using JavaScript. One can try to access the website though directly using some Python code:
import ssl
conn = ssl.create_connection(('google.com',443))
ctx = ssl.create_default_context()
conn = ctx.wrap_socket(conn, server_hostname = 'google.com')
print(conn.getpeercert())
For more details see here

Prophet
- 32,350
- 22
- 54
- 79
-
Yeah, I've seen it, but thought, that may be there is a way to do it via selenium... since it emulates browser and I can get this info via my browser. – JhonyBony Mar 15 '22 at 14:50
-
AFAIK and accordingly to that answer there is no way to do that with Selenium – Prophet Mar 15 '22 at 15:01