func main() {
	c, err := client.NewClientFromFile(certFile, keyFile, caFile)
	if err != nil {
		log.Fatal(err)
	}
	c.Config.InsecureSkipVerify = insecureSkipVerify

	if server != "" {
		in := &testapi.Input{
			Keyserver: server,
			CertsPEM:  testcerts,
			Domain:    domain,
			ServerIP:  serverIP,
		}
		results, err := tests.RunAPITests(in, c, testLen, workers)
		if err != nil {
			log.Fatal(err)
		}
		out, err := json.MarshalIndent(results, "", "  ")
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(string(out))
	}

	if apiPort != "" {
		log.Fatal(tests.ListenAndServeAPI(net.JoinHostPort("", apiPort), testLen, workers, c))
	}
}
Beispiel #2
0
func main() {
	c, err := client.NewClientFromFile(certFile, keyFile, caFile)
	if err != nil {
		log.Fatal(err)
	}

	privkeys, err := c.RegisterDir(server, pubkeyDir, LoadPEMPubKey)
	if err != nil {
		log.Fatal(err)
	}

	tests.RunServerTests(testLen, workers, c, server, privkeys)
}
Beispiel #3
0
func main() {
	c, err := client.NewClientFromFile(certFile, keyFile, caFile)
	if err != nil {
		log.Fatal(err)
	}

	if err := testConnect(c, server); err != nil {
		log.Fatal(err)
	}

	pubkeys, err := LoadPubKeysFromDir(pubkeyDir)
	if err != nil {
		log.Fatal(err)
	}

	privkeys := make([]*client.PrivateKey, len(pubkeys))
	for i := range pubkeys {
		var err error
		if privkeys[i], err = c.RegisterPublicKey(server, pubkeys[i]); err != nil {
			log.Fatal(err)
		}

		if err := testKey(privkeys[i]); err != nil {
			log.Fatal(err)
		}
	}

	log.Fatal(loadTest(func() error {
		if err := testConnect(c, server); err != nil {
			return err
		}

		for _, key := range privkeys {
			if err := testKey(key); err != nil {
				return err
			}
		}
		return nil
	}))
}
Beispiel #4
0
// Set up compatible server and client for use by tests.
func init() {
	var err error
	var pemBytes []byte
	var p *pem.Block
	var priv crypto.Signer
	var pub crypto.PublicKey

	log.Level = log.LevelFatal

	s, err = server.NewServerFromFile(serverCert, serverKey, keylessCA, serverAddr, "")
	if err != nil {
		log.Fatal(err)
	}

	if pemBytes, err = ioutil.ReadFile(rsaPrivKey); err != nil {
		log.Fatal(err)
	}
	p, _ = pem.Decode(pemBytes)
	if priv, err = x509.ParsePKCS1PrivateKey(p.Bytes); err != nil {
		log.Fatal(err)
	}
	if err = s.Keys.Add(nil, priv); err != nil {
		log.Fatal(err)
	}

	if pemBytes, err = ioutil.ReadFile(ecdsaPrivKey); err != nil {
		log.Fatal(err)
	}
	p, _ = pem.Decode(pemBytes)
	if priv, err = x509.ParseECPrivateKey(p.Bytes); err != nil {
		log.Fatal(err)
	}
	if err = s.Keys.Add(nil, priv); err != nil {
		log.Fatal(err)
	}

	listening := make(chan bool)
	go func() {
		listening <- true
		if err := s.ListenAndServe(); err != nil {
			log.Fatal(err)
		}
	}()
	<-listening

	if c, err = client.NewClientFromFile(clientCert, clientKey, keyserverCA); err != nil {
		log.Fatal(err)
	}

	if pemBytes, err = ioutil.ReadFile(rsaPubKey); err != nil {
		log.Fatal(err)
	}
	p, _ = pem.Decode(pemBytes)
	if pub, err = x509.ParsePKIXPublicKey(p.Bytes); err != nil {
		log.Fatal(err)
	}
	if rsaKey, err = c.RegisterPublicKey(serverAddr, pub); err != nil {
		log.Fatal(err)
	}

	if pemBytes, err = ioutil.ReadFile(ecdsaPubKey); err != nil {
		log.Fatal(err)
	}
	p, _ = pem.Decode(pemBytes)
	if pub, err = x509.ParsePKIXPublicKey(p.Bytes); err != nil {
		log.Fatal(err)
	}
	if ecdsaKey, err = c.RegisterPublicKey(serverAddr, pub); err != nil {
		log.Fatal(err)
	}
}