There’s no need to build this all yourself - just install an SSL on your site, and you are good to go!