// TestBadReGenerator ensures that a request that fails the ParseCSR is
// not processed.
TestBadReGenerator ensures that a request that fails the ParseCSR is
not processed.
// TestBadReGenerator ensures that a request that fails the ParseCSR is // not processed .
func TestBadReGenerate(t *testing.T) {
	var req = &CertificateRequest{
		Names: []Name{
			{
				C:  "US",
				ST: "California",
				L:  "San Francisco",
				O:  "CloudFlare",
				OU: "Systems Engineering",
			},
		},
		CN:         "cloudflare.com",
		Hosts:      []string{"cloudflare.com", "www.cloudflare.com", "192.168.0.1"},
		KeyRequest: &KeyRequest{"ecdsa", 256},
	}
	_, key, err := ParseRequest(req)
	if err != nil {
		t.Fatalf("%v", err)
	}
	priv, err := helpers.ParsePrivateKeyPEM(key)
	if err != nil {
		t.Fatalf("%v", err)
	}
	csr, err := Generate(priv, req)
	if err != nil {
		t.Fatalf("%v", err)
	}
	block := pem.Block{
		Type: "CERTIFICATE REQUEST",
		Headers: map[string]string{
			"Location": "UCSD",
		},
		Bytes: csr,
	}
	csr = pem.EncodeToMemory(&block)
	_, err = Regenerate(priv, csr)
	if err == nil {
		t.Fatalf("%v", err)
	}
}
func TestBadReGenerate ( t * testing . T ) { var req = & CertificateRequest { Names : [ ] Name { { C : " " , ST : " " , L : " " , O : " " , OU : " " , } , } , CN : " " , Hosts : [ ] string { " " , " " , " " } , KeyRequest : & KeyRequest { " " , 256 } , } _ , key , err := ParseRequest ( req ) if err != nil { t . Fatalf ( " " , err ) } priv , err := helpers . ParsePrivateKeyPEM ( key ) if err != nil { t . Fatalf ( " " , err ) } csr , err := Generate ( priv , req ) if err != nil { t . Fatalf ( " " , err ) } block := pem . Block { Type : " " , Headers : map [ string ] string { " " : " " , } , Bytes : csr , } csr = pem . EncodeToMemory ( & block ) _ , err = Regenerate ( priv , csr ) if err == nil { t . Fatalf ( " " , err ) } }
TestBadReGenerator ensures that a request that fails the ParseCSR is
not processed.
TestBadReGenerator ensures that a request that fails the ParseCSR is not processed .