7 changed files with 140 additions and 9 deletions
@ -0,0 +1,33 @@
|
||||
`gmitohtml` loads its configuration from `~/.config/gmitohtml/config.yaml` by |
||||
default. You may specify a different location via the `--config` argument. |
||||
|
||||
# Configuration options |
||||
|
||||
## Client certificates |
||||
|
||||
Client certificates may be specified via the `Certs` option. |
||||
|
||||
To generate a client certificate, run the following: |
||||
|
||||
```bash |
||||
openssl req -x509 -out localhost.crt -keyout localhost.key \ |
||||
-newkey rsa:2048 -nodes -sha256 \ |
||||
-subj '/CN=localhost' -extensions EXT -config <( \ |
||||
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") |
||||
``` |
||||
|
||||
Files `localhost.crt` and `localhost.key` are generated. Rename these files to |
||||
match the domain where the certificate will be used. |
||||
|
||||
# Example config.yaml |
||||
|
||||
```yaml |
||||
certs: |
||||
astrobotany.mozz.us: |
||||
cert: /home/dioscuri/.config/gmitohtml/astrobotany.mozz.us.crt |
||||
key: /home/dioscuri/.config/gmitohtml/astrobotany.mozz.us.crt |
||||
gemini.rocks: |
||||
cert: /home/dioscuri/.config/gmitohtml/gemini.rocks.crt |
||||
key: /home/dioscuri/.config/gmitohtml/gemini.rocks.key |
||||
|
||||
``` |
@ -0,0 +1,44 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"crypto/tls" |
||||
"errors" |
||||
"io/ioutil" |
||||
|
||||
"gopkg.in/yaml.v3" |
||||
) |
||||
|
||||
type certConfig struct { |
||||
Cert string |
||||
Key string |
||||
|
||||
cert tls.Certificate |
||||
} |
||||
|
||||
type appConfig struct { |
||||
Certs map[string]*certConfig |
||||
} |
||||
|
||||
var config = &appConfig{ |
||||
Certs: make(map[string]*certConfig), |
||||
} |
||||
|
||||
func readconfig(configPath string) error { |
||||
if configPath == "" { |
||||
return errors.New("file unspecified") |
||||
} |
||||
|
||||
configData, err := ioutil.ReadFile(configPath) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
var newConfig *appConfig |
||||
err = yaml.Unmarshal(configData, &newConfig) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
config = newConfig |
||||
|
||||
return nil |
||||
} |
@ -1,3 +1,5 @@
|
||||
module gitlab.com/tslocum/gmitohtml |
||||
|
||||
go 1.15 |
||||
|
||||
require gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 |
||||
|
@ -0,0 +1,4 @@
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= |
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= |
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Loading…
Reference in new issue