// TestDefaultKeyRequest makes sure that certificate requests without
// explicit key requests fall back to the default key request.
TestDefaultKeyRequest makes sure that certificate requests without
explicit key requests fall back to the default key request.
// TestDefaultKeyRequest makes sure that certificate requests without // explicit key requests fall back to the default key request .
func TestDefaultKeyRequest(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", "jdoe@example.com", "https://www.cloudflare.com"},
	}
	_, priv, err := ParseRequest(req)
	if err != nil {
		t.Fatalf("%v", err)
	}
	block, _ := pem.Decode(priv)
	if block == nil {
		t.Fatal("Bad private key was generated!")
	}
	DefaultKeyRequest := NewKeyRequest()
	switch block.Type {
	case "RSA PRIVATE KEY":
		if DefaultKeyRequest.Algo() != "rsa" {
			t.Fatal("Invalid default key request.")
		}
	case "EC PRIVATE KEY":
		if DefaultKeyRequest.Algo() != "ecdsa" {
			t.Fatal("Invalid default key request.")
		}
	}
}
func TestDefaultKeyRequest ( t * testing . T ) { var req = & CertificateRequest { Names : [ ] Name { { C : " " , ST : " " , L : " " , O : " " , OU : " " , } , } , CN : " " , Hosts : [ ] string { " " , " " , " " , " " } , } _ , priv , err := ParseRequest ( req ) if err != nil { t . Fatalf ( " " , err ) } block , _ := pem . Decode ( priv ) if block == nil { t . Fatal ( " " ) } DefaultKeyRequest := NewKeyRequest ( ) switch block . Type { case " " : if DefaultKeyRequest . Algo ( ) != " " { t . Fatal ( " " ) } case " " : if DefaultKeyRequest . Algo ( ) != " " { t . Fatal ( " " ) } } }
TestDefaultKeyRequest makes sure that certificate requests without
explicit key requests fall back to the default key request.
TestDefaultKeyRequest makes sure that certificate requests without explicit key requests fall back to the default key request .
// If the default key type changes, this will need to be changed.