Turn on HTTPS for all GitHub Pages

| github | ssl

GitHub just announced that all github.io sites can enforce the use of HTTPS. Previously GitHub supported HTTPS on these sites, but you couldn’t force users to use HTTPS other than using a javascript redirect hack, or putting a CDN infront of GitHub. Now by checking a single box you can force users to the secure version:

Enforce HTTPS Checkbox

Sadly I have far too many repositories, and I don’t recall which one uses pages. I figured it would be easy to hit GitHub’s API and enabled this. The API doesn’t directly support enabling HTTPS, so instead I wrote a quick script to list all repos with GitHub pages:

#!/usr/bin/env python
# Prints a list of all owned repositories with pages.
# by Andrew Brampton 2016 https://bramp.net
import requests

headers = {'Authorization': 'token XXXXX'} # Replace XXXX with a token from https://github.com/settings/tokens
params = {'type': 'owner', 'page': 1}

while True:
	r = requests.get('https://api.github.com/user/repos', params=params, headers=headers)
	repos = r.json()
	if not repos:

	for repo in repos:
		if repo['has_pages']:
			print "%32s %s/settings" %(repo['name'], repo['html_url'])

	params['page'] += 1

Download turn-on-github-ssl.py

This print out something like so:

$ ./turn-on-github-ssl.py

                blog https://github.com/bramp/blog/settings
  ffmpeg-cli-wrapper https://github.com/bramp/ffmpeg-cli-wrapper/settings
js-sequence-diagrams https://github.com/bramp/js-sequence-diagrams/settings
           js-sudoku https://github.com/bramp/js-sudoku/settings
        nodewii-talk https://github.com/bramp/nodewii-talk/settings
             prob.js https://github.com/bramp/prob.js/settings
                test https://github.com/bramp/test/settings
              unsafe https://github.com/bramp/unsafe/settings

Now click on each URL, and just check the box.

comments powered by Disqus