Skip to content

Instantly share code, notes, and snippets.

@nezarfadle
Last active September 13, 2019 11:29
Show Gist options
  • Save nezarfadle/6ec67a31421774c698cd100176b11b0f to your computer and use it in GitHub Desktop.
Save nezarfadle/6ec67a31421774c698cd100176b11b0f to your computer and use it in GitHub Desktop.

How to test your SSL setup with Python

1- Install Selenium

pip install -U selenium

2- Download Firefox from here and exract it next to your Test file:

Download Firefox for Linux
Download Firefox for Windows
You can find all Firefox releases from here

3- Create a GoogleSSLSetupTest.py file and paste this code ( This is your test file ):

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

EXE_PATH = r'geckodriver.exe'
options = Options()

options.headless = True
driver = webdriver.Firefox(executable_path=EXE_PATH, options=options)

driver.get('http://google.com')

url = driver.current_url

if url.startswith("https://"):
        print "Pass"
else:
        print "Failed"

driver.quit()

The code above will test that we have been redirected successfully to a secure HTTPS connection when we request a none secure HTTP connection.

How to run the test

python GoogleSSLSetupTest.py

If the test successe it will print out Pass, else it will print Failed.

🔥 Note: You can take this concept further by intergate it with your Testing Framework
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment