aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-05-22 00:52:06 +0100
committerNiall Sheridan <nsheridan@gmail.com>2016-05-22 00:52:06 +0100
commit1ca20e5b7a5fa803aced63ddaedf52d1064ce43a (patch)
tree86e86dbe51adb29c3f0011614a06676c1593753a /client
parentdda973d04d7cda9934a0fdd4ecb0d5055423a335 (diff)
Open the browser automatically
Diffstat (limited to 'client')
-rw-r--r--client/main.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/client/main.go b/client/main.go
index 1b35d28..355f229 100644
--- a/client/main.go
+++ b/client/main.go
@@ -13,13 +13,14 @@ import (
"time"
"github.com/nsheridan/cashier/lib"
+ "github.com/pkg/browser"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
)
var (
- url = flag.String("url", "http://localhost:10000/sign", "Signing URL")
- keybits = flag.Int("bits", 4096, "Key size")
+ ca = flag.String("ca", "http://localhost:10000", "CA server")
+ keybits = flag.Int("bits", 4096, "Key size. Ignored for ed25519 keys")
validity = flag.Duration("validity", time.Hour*24, "Key validity")
keytype = flag.String("key_type", "rsa", "Type of private key to generate - rsa, ecdsa or ed25519")
)
@@ -37,7 +38,7 @@ func installCert(a agent.Agent, cert *ssh.Certificate, key key) error {
}
func send(s []byte, token string) (*lib.SignResponse, error) {
- req, err := http.NewRequest("POST", *url, bytes.NewReader(s))
+ req, err := http.NewRequest("POST", *ca+"/sign", bytes.NewReader(s))
if err != nil {
return nil, err
}
@@ -95,6 +96,10 @@ func sign(pub ssh.PublicKey, token string) (*ssh.Certificate, error) {
func main() {
flag.Parse()
+ fmt.Printf("Your browser has been opened to visit %s\n", *ca)
+ if err := browser.OpenURL(*ca); err != nil {
+ fmt.Println("Error launching web browser. Go to the link in your web browser")
+ }
priv, pub, err := generateKey(*keytype, *keybits)
if err != nil {
log.Fatalln("Error generating key pair: ", err)