blob: 2fcfaf05c28dacf05a02536ccf7dbe0d0fe5f837 [file] [log] [blame]
package main
import (
"io/ioutil"
"os"
"github.com/golang/glog"
pb "code.hackerspace.pl/hscloud/cluster/prodvider/proto"
"code.hackerspace.pl/hscloud/go/pki"
)
func useHSPKIKeys(keys *pb.HSPKIKeys) {
path, err := pki.DeveloperCredentialsLocation()
err = os.MkdirAll(path, 0700)
if err != nil {
glog.Exitf("mkdir %q: %v", path, err)
}
for _, el := range []struct {
target string
data []byte
}{
{path + "/ca.crt", keys.Ca},
{path + "/tls.crt", keys.Cert},
{path + "/tls.key", keys.Key},
} {
err := ioutil.WriteFile(el.target, el.data, 400)
if err != nil {
glog.Exitf("Failed to write %q: %v", el.target, err)
}
}
}