Skip to content

Commit

Permalink
A collection of minor improvements.
Browse files Browse the repository at this point in the history
* Only look for valid YAML/JSON files in the cert spec
  dir (e.g. fix #33).
* Update Travis to use Go 1.9 to fix a Go bug in the
  user lookups (#30).
* Update README to include CA file path writing.
* Remove the informational message about not writing a CA file
  if no file path was provided. This was useful in testing,
  but has caused a great deal of confusion among users.
* Bump the patch version to trigger a release using the new Go version.

Use Go-1.9 and add CA file writes to README.
  • Loading branch information
kisom committed Nov 9, 2017
1 parent f9e54e5 commit 249ace2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: go
dist: trusty
sudo: false
go:
- 1.8.x
- 1.9.x
install:
- go get github.com/Masterminds/glide
script:
Expand All @@ -11,7 +11,7 @@ script:
jobs:
include:
- stage: Cross-Build
go: 1.8.x
go: 1.9.x
env:
- CGO_ENABLED=0
script:
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ When run without any subcommands, certmgr will start monitoring
certificates. The configuration and specifications can be validated
using the `check` subcommand.

**Note**: due to a [bug](https://github.com/golang/go/issues/19395) in
the os/user package, `certmgr` requires Go 1.9 or later to use the
user/group functionality in file specifications.

## Web server

When appropriately configured, `certmgr` will start a web server that
Expand Down Expand Up @@ -137,7 +141,12 @@ An example certificate spec:
"remote": "ca.example.net:8888",
"auth_key": "012345678012345678",
"label": "www_ca",
"profile": "three-month"
"profile": "three-month",
"file": {
"path": "/etc/myservice/ca.pem",
"owner": "www-data",
"group": "www-data"
}
}
}
```
Expand Down Expand Up @@ -183,6 +192,8 @@ The CA specification contains the following fields:
* `auth_key`: the authentication key used to request a certificate.
* `label`: the CA to use for the certificate.
* `profile`: the CA profile that should be used.
* `file`: if this is included, the CA certificate will be saved here. It
follows the same file specification format above.

## Subcommands

Expand Down
4 changes: 3 additions & 1 deletion cert/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ type CA struct {
// CA certificate to disk.
func (ca *CA) Load() error {
if ca.File == nil {
log.Info("cert: no CA file provided, won't write to disk")
// NB: this used to be an info message, but it caused
// more confusion than anything else.
log.Debug("cert: no CA file provided, won't write the CA file to disk")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/spf13/viper"
)

var currentVersion = "1.4.2"
var currentVersion = "1.4.3"

var versionCmd = &cobra.Command{
Use: "version",
Expand Down
11 changes: 11 additions & 0 deletions mgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ var validActions = map[string]bool{
"nop": true,
}

var validExtensions = map[string]bool{
".json": true,
".yaml": true,
".yml": true,
}

// Load reads the certificate specs from the spec directory.
func (m *Manager) Load() error {
if m.Certs != nil || len(m.Certs) > 0 {
Expand All @@ -160,6 +166,11 @@ func (m *Manager) Load() error {
return filepath.SkipDir
}

ext := filepath.Ext(path)
if !validExtensions[ext] {
return nil
}

log.Info("manager: loading spec from ", path)
cert, err := cert.Load(path, m.DefaultRemote, m.before)
if err != nil {
Expand Down

0 comments on commit 249ace2

Please sign in to comment.