Skip to content
Snippets Groups Projects
setup.go 428 B
Newer Older
Gabriel Zachmann's avatar
Gabriel Zachmann committed
package main

import (
	"io/ioutil"
	"log"

	"github.com/zachmann/mytoken/internal/config"
Gabriel Zachmann's avatar
Gabriel Zachmann committed

	"github.com/zachmann/mytoken/internal/jws"
)

func main() {
	config.LoadForSetup()
	sk, _, err := jws.GenerateKeyPair()
	if err != nil {
		log.Fatal(err)
	}
	str := jws.ExportPrivateKeyAsPemStr(sk)
	filepath := config.Get().Signing.KeyFile
Gabriel Zachmann's avatar
Gabriel Zachmann committed
	ioutil.WriteFile(filepath, []byte(str), 0600)
	log.Printf("Wrote key to '%s'.\n", filepath)
Gabriel Zachmann's avatar
Gabriel Zachmann committed
}