Skip to content

Commit 35ede74

Browse files
authored
Merge pull request #596 from gdbelvin/name
Allow configuration of PKCS11 subject name
2 parents e17fc43 + 595f125 commit 35ede74

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

cmd/step-pkcs11-init/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ type Config struct {
3535
RootOnly bool
3636
RootObject string
3737
RootKeyObject string
38+
RootSubject string
3839
RootPath string
3940
CrtObject string
4041
CrtPath string
4142
CrtKeyObject string
43+
CrtSubject string
4244
CrtKeyPath string
4345
SSHHostKeyObject string
4446
SSHUserKeyObject string
@@ -101,9 +103,11 @@ func main() {
101103
flag.StringVar(&c.RootObject, "root-cert", "pkcs11:id=7330;object=root-cert", "PKCS #11 URI with object id and label to store the root certificate.")
102104
flag.StringVar(&c.RootPath, "root-cert-path", "root_ca.crt", "Location to write the root certificate.")
103105
flag.StringVar(&c.RootKeyObject, "root-key", "pkcs11:id=7330;object=root-key", "PKCS #11 URI with object id and label to store the root key.")
106+
flag.StringVar(&c.RootSubject, "root-name", "PKCS #11 Smallstep Root", "Subject and Issuer of the root certificate.")
104107
flag.StringVar(&c.CrtObject, "crt-cert", "pkcs11:id=7331;object=intermediate-cert", "PKCS #11 URI with object id and label to store the intermediate certificate.")
105108
flag.StringVar(&c.CrtPath, "crt-cert-path", "intermediate_ca.crt", "Location to write the intermediate certificate.")
106109
flag.StringVar(&c.CrtKeyObject, "crt-key", "pkcs11:id=7331;object=intermediate-key", "PKCS #11 URI with object id and label to store the intermediate certificate.")
110+
flag.StringVar(&c.CrtSubject, "crt-name", "PKCS #11 Smallstep Intermediate", "Subject of the intermediate certificate.")
107111
flag.StringVar(&c.CrtKeyPath, "crt-key-path", "intermediate_ca_key", "Location to write the intermediate private key.")
108112
flag.StringVar(&c.SSHHostKeyObject, "ssh-host-key", "pkcs11:id=7332;object=ssh-host-key", "PKCS #11 URI with object id and label to store the key used to sign SSH host certificates.")
109113
flag.StringVar(&c.SSHUserKeyObject, "ssh-user-key", "pkcs11:id=7333;object=ssh-user-key", "PKCS #11 URI with object id and label to store the key used to sign SSH user certificates.")
@@ -300,8 +304,8 @@ func createPKI(k kms.KeyManager, c Config) error {
300304
BasicConstraintsValid: true,
301305
MaxPathLen: 1,
302306
MaxPathLenZero: false,
303-
Issuer: pkix.Name{CommonName: "PKCS #11 Smallstep Root"},
304-
Subject: pkix.Name{CommonName: "PKCS #11 Smallstep Root"},
307+
Issuer: pkix.Name{CommonName: c.RootSubject},
308+
Subject: pkix.Name{CommonName: c.RootSubject},
305309
SerialNumber: mustSerialNumber(),
306310
SubjectKeyId: mustSubjectKeyID(resp.PublicKey),
307311
AuthorityKeyId: mustSubjectKeyID(resp.PublicKey),
@@ -379,7 +383,7 @@ func createPKI(k kms.KeyManager, c Config) error {
379383
MaxPathLen: 0,
380384
MaxPathLenZero: true,
381385
Issuer: root.Subject,
382-
Subject: pkix.Name{CommonName: "YubiKey Smallstep Intermediate"},
386+
Subject: pkix.Name{CommonName: c.CrtSubject},
383387
SerialNumber: mustSerialNumber(),
384388
SubjectKeyId: mustSubjectKeyID(publicKey),
385389
}

0 commit comments

Comments
 (0)