diff options
author | Gibheer <gibheer@gmail.com> | 2015-02-03 21:56:06 +0100 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2015-02-03 21:56:06 +0100 |
commit | 58100320b7969cd2a58ff33cd6f38b45d2e7b02a (patch) | |
tree | a9020bfae766592f0e1f455ae7d446da19eb5082 /sign_request.go | |
parent | 2fcde165befa91df7657b58cb027b24c92501198 (diff) |
add last missing fields
This adds the last missing fields of the pkix.Name and also adds a loop
which converts all fields from comma separated list to an array.
Diffstat (limited to 'sign_request.go')
-rw-r--r-- | sign_request.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sign_request.go b/sign_request.go index 372db75..2f7dd7b 100644 --- a/sign_request.go +++ b/sign_request.go @@ -11,6 +11,7 @@ import ( "io" "net" "os" + "reflect" "regexp" ) @@ -53,6 +54,10 @@ func create_sign_request() { func parse_sign_flags() SignFlags { dns_names := "" // string to hold the alternative names ips := "" // string to hold the alternative ips + var container struct { + Country, Organization, OrganizationalUnit, Locality, Province, + StreetAddress, PostalCode string + } flags := SignFlags{} fs := flag.NewFlagSet("create-cert-sign", flag.ExitOnError) @@ -64,7 +69,13 @@ func parse_sign_flags() SignFlags { fs.StringVar(&flags.BaseAttributes.SerialNumber, "serial", "1", "serial number for the request") fs.StringVar(&dns_names, "names", "", "alternative names (comma separated)") fs.StringVar(&ips, "ips", "", "alternative IPs (comma separated)") - + fs.StringVar(&container.Country, "country", "", "country of the organization") + fs.StringVar(&container.Organization, "organization", "", "the name of the organization") + fs.StringVar(&container.OrganizationalUnit, "org-unit", "", "the organizational unit") + fs.StringVar(&container.Locality, "city", "", "the city or locality") + fs.StringVar(&container.Province, "province", "", "the province") + fs.StringVar(&container.StreetAddress, "street", "", "the street address for the cert") + fs.StringVar(&container.PostalCode, "postal-code", "", "the postal code of the city") fs.Parse(os.Args[2:]) // convert array flags to config structs @@ -74,6 +85,14 @@ func parse_sign_flags() SignFlags { flags.IPAddresses = append(flags.IPAddresses, net.ParseIP(sip)) } + container_type := reflect.ValueOf(container) + config_type := reflect.ValueOf(&flags.BaseAttributes).Elem() + for i := 0; i < container_type.NumField(); i++ { + field := container_type.Field(i) + new_field := config_type.FieldByName(container_type.Type().Field(i).Name) + new_field.Set(reflect.ValueOf(COMMA_SPLIT.Split(field.String(), -1))) + } + return flags } |