Ejemplo n.º 1
0
func (c *Certs) setupKeys() {
	for _, cert := range c.Certificates {
		rsaBitsLenght := 2048
		if cert.CertConfig.KeyLength > 0 {
			rsaBitsLenght = cert.CertConfig.KeyLength
		}
		cert.PrivateKey = key.GenerateKey(cert.CertConfig.KeyType, rsaBitsLenght)
	}
}
Ejemplo n.º 2
0
func createInterCA() (*x509.Certificate, interface{}) {
	interCaPriv := key.GenerateKey("RSA", 1024) // use small key for fast generation
	interCaData := Certificate{
		Id:                 "two",
		Country:            "SE",
		Organization:       "test",
		OrganizationalUnit: "WebInterCA",
		CA:                 true,
		PrivateKey:         interCaPriv,
		ValidFrom:          time.Now(),
		ValidTo:            time.Now().AddDate(1, 0, 0),
	}
	return CreateCertificateTemplate(interCaData), interCaPriv
}
Ejemplo n.º 3
0
func createCA() (*x509.Certificate, interface{}) {
	caPriv := key.GenerateKey("RSA", 1024)
	caData := Certificate{
		Id:                 "one",
		Country:            "SE",
		Organization:       "test",
		OrganizationalUnit: "WebCA",
		CA:                 true,
		PrivateKey:         caPriv,
		ValidFrom:          time.Now(),
		ValidTo:            time.Now().AddDate(1, 0, 0),
	}

	return CreateCertificateTemplate(caData), caPriv
}
Ejemplo n.º 4
0
func createClient() (*x509.Certificate, interface{}) {
	clientPriv := key.GenerateKey("RSA", 1024)
	clientData := Certificate{
		Id:                 "three",
		Country:            "SE",
		Organization:       "test",
		OrganizationalUnit: "Web",
		CA:                 false,
		CommonName:         "www.baz.se",
		AlternativeNames:   []string{"www.foo.se", "www.bar.se"},
		PrivateKey:         clientPriv,
		ValidFrom:          time.Now(),
		ValidTo:            time.Now().AddDate(1, 0, 0),
	}
	return CreateCertificateTemplate(clientData), clientPriv
}