【英文】在MacOS上生成CA证书部署HTTPS开发环境

Preface

Generating CA Certificates for Deploying HTTPS Development Environment on MacOS

Installing mkcert

  • Install mkcert for generating CA certificates
1
brew install mkcert

Installing nss (optional)

  • Install nss for Firefox support
1
brew install nss

Deploying CA Certificates

1
2
mkdir ~/.cert
mkcert -key-file ~/.cert/key.pem -cert-file ~/.cert/cert.pem "localhost"
  • At this point, the CA certificate for localhost is included in the browser

Applying CA Certificates on the Website

Go Gin

  • When starting the server, change the Run function to RunTLS function
1
app.RunTLS("localhost:8080", "~/.cert/cert.pem", "~/.cert/key.pem")

Completion

  • Visit https://localhost:8080 in the browser, and the address bar will indicate that it is a secure HTTPS site

References

LeanCloud on Zhihu