Skip to content

Commit

Permalink
Merge pull request #53 from anguslees/dumpcert
Browse files Browse the repository at this point in the history
kubeseal: Add --fetch-cert to dump cert to stdout
  • Loading branch information
anguslees authored Sep 21, 2017
2 parents 1530705 + 6da235d commit dd7c385
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ and needs to be available wherever `kubeseal` is going to be
used. The certificate is not secret information, although you need to
ensure you are using the correct file.

`kubeseal` will fetch the certificate from the controller at
runtime (requires secure access to the Kubernetes API server), but can
also be read from a local file for offline situations (eg: automated
jobs). The certificate is also printed to the controller log on
startup.
`kubeseal` will fetch the certificate from the controller at runtime
(requires secure access to the Kubernetes API server), which is
convenient for interactive use. The recommended automation workflow
is to store the certificate to local disk with `kubeseal --fetch-cert
>mycert.pem`, and use it offline with `kubeseal --cert mycert.pem`.
The certificate is also printed to the controller log on startup.

### Installation from source

Expand Down
8 changes: 8 additions & 0 deletions cmd/kubeseal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
controllerNs = flag.String("controller-namespace", api.NamespaceSystem, "Namespace of sealed-secrets controller.")
controllerName = flag.String("controller-name", "sealed-secrets-controller", "Name of sealed-secrets controller.")
outputFormat = flag.String("format", "json", "Output format for sealed secret. Either json or yaml")
dumpCert = flag.Bool("fetch-cert", false, "Write certificate to stdout. Useful for later use with --cert")

clientConfig clientcmd.ClientConfig
)
Expand Down Expand Up @@ -219,6 +220,13 @@ func main() {
}
defer f.Close()

if *dumpCert {
if _, err := io.Copy(os.Stdout, f); err != nil {
panic(err.Error())
}
return
}

pubKey, err := parseKey(f)
if err != nil {
panic(err.Error())
Expand Down

0 comments on commit dd7c385

Please sign in to comment.