golang-https-example/README.md

53 lines
1.1 KiB
Markdown
Raw Normal View History

2020-04-28 05:09:34 +00:00
# golang-https-example
2015-07-13 22:35:12 +00:00
2020-04-28 05:09:34 +00:00
A TLS / SSL enabled WebServer in Go, done right - includes valid https certificates.
2015-07-13 22:35:12 +00:00
2020-04-28 05:09:34 +00:00
# Install
2015-07-13 22:35:12 +00:00
Install the server and some certificates
```bash
# Clone this repo
2020-04-28 05:09:34 +00:00
git clone ssh://gitea@git.coolaj86.com:22042/coolaj86/golang-https-example.git
2015-07-13 22:35:12 +00:00
pushd golang-https-example
# Clone some valid dummy certificates
2020-04-28 05:09:34 +00:00
git clone git@example.com:example/localhost.example.com-certificates.git \
./etc/letsencrypt/live/localhost.rootprojects.org/
2015-07-13 22:35:12 +00:00
```
2020-04-28 05:09:34 +00:00
# Test
2015-07-13 22:35:12 +00:00
Run the server
```bash
# Run the Code
2015-07-14 01:30:27 +00:00
go run serve.go \
--port 8443 \
--letsencrypt-path=./etc/letsencrypt/live/
2015-07-13 22:35:12 +00:00
```
View it in your browser
2020-04-28 05:09:34 +00:00
<https://localhost.rootprojects.org:8443>
2015-07-13 22:35:12 +00:00
Test it with `openssl`
```bash
openssl s_client -showcerts \
-connect localhost:8443 \
2020-04-28 05:09:34 +00:00
-servername localhost.rootprojects.org \
-CAfile ./etc/letsencrypt/live/localhost.rootprojects.org/certs/ca/root.pem
2015-07-13 22:35:12 +00:00
```
Test it with `curl`
```bash
# should work
2020-04-28 05:09:34 +00:00
curl https://localhost.rootprojects.org:8443
2015-07-13 22:35:12 +00:00
# if the Root CA isn't in your bundle
2020-04-28 05:09:34 +00:00
curl https://localhost.rootprojects.org:8443 \
--cacert=./etc/letsencrypt/live/localhost.rootprojects.org/certs/ca/root.pem
2015-07-13 22:35:12 +00:00
```