Skip to content

Commit a5a6b99

Browse files
authored
Merge pull request #426 from smallstep/mariano/no-pin
Do not enforce pin on pkcs11 kms
2 parents e352efd + 8f5d176 commit a5a6b99

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

kms/pkcs11/pkcs11.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ func New(_ context.Context, opts apiv1.Options) (*PKCS11, error) {
106106
config.Path = defaultModule
107107
}
108108

109+
// We will allow empty pins as some modules might not have a pin by default.
110+
// This is the case for softtoken, which is used to read NSS databases.
109111
config.Pin = u.Pin()
110112
if config.Pin == "" && opts.Pin != "" {
111113
config.Pin = opts.Pin
@@ -114,8 +116,6 @@ func New(_ context.Context, opts apiv1.Options) (*PKCS11, error) {
114116
switch {
115117
case config.TokenLabel == "" && config.TokenSerial == "" && config.SlotNumber == nil:
116118
return nil, errors.New("kms uri 'token', 'serial' or 'slot-id' are required")
117-
case config.Pin == "":
118-
return nil, errors.New("kms 'pin' cannot be empty")
119119
case config.TokenLabel != "" && config.TokenSerial != "":
120120
return nil, errors.New("kms uri 'token' and 'serial' are mutually exclusive")
121121
case config.TokenLabel != "" && config.SlotNumber != nil:

kms/pkcs11/pkcs11_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ func TestNew(t *testing.T) {
6969
URI: "pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=pkcs11-test",
7070
Pin: "passowrd",
7171
}}, k, false},
72+
{"ok no pin", args{context.Background(), apiv1.Options{
73+
Type: "pkcs11",
74+
URI: "pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=pkcs11-test",
75+
}}, k, false},
7276
{"ok with missing module", args{context.Background(), apiv1.Options{
7377
Type: "pkcs11",
7478
URI: "pkcs11:token=pkcs11-test",
@@ -77,10 +81,6 @@ func TestNew(t *testing.T) {
7781
{"fail missing uri", args{context.Background(), apiv1.Options{
7882
Type: "pkcs11",
7983
}}, nil, true},
80-
{"fail missing pin", args{context.Background(), apiv1.Options{
81-
Type: "pkcs11",
82-
URI: "pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=pkcs11-test",
83-
}}, nil, true},
8484
{"fail missing token/serial/slot-id", args{context.Background(), apiv1.Options{
8585
Type: "pkcs11",
8686
URI: "pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so",

0 commit comments

Comments
 (0)