/* Generate a self-singed certificate and key which are plced into the files with the given names passed in. */ func mk_cert(cert_name string, cfname *string, kfname *string) (err error) { this_host, _ := os.Hostname() tokens := strings.Split(this_host, ".") dns_list := make([]string, 3) dns_list[0] = "localhost" dns_list[1] = this_host dns_list[2] = tokens[0] err = security.Mk_cert(1024, &cert_name, dns_list, cfname, kfname) return err }
/* Test the creation of a cert and related key */ func TestSecurity_cert(t *testing.T) { dns_list := make([]string, 2) dns_list[0] = "localhost" this_host, err := os.Hostname() if err == nil { tokens := strings.Split(this_host, ".") dns_list[1] = tokens[0] } cert_fname := "test_cert.pem" key_fname := "test_key.pem" cert_name := "foo_cert" err = security.Mk_cert(1024, &cert_name, dns_list, &cert_fname, &key_fname) if err != nil { fmt.Fprintf(os.Stderr, "failed: %s", err) t.Fail() } }