File tree 5 files changed +56
-6
lines changed
e2e_tests/tests/all_providers/config
5 files changed +56
-6
lines changed Original file line number Diff line number Diff line change @@ -121,8 +121,8 @@ key_info_manager = "on-disk-manager"
121
121
# library_path = "/usr/local/lib/softhsm/libsofthsm2.so"
122
122
# (Required) PKCS 11 slot that will be used by Parsec.
123
123
# slot_number = 123456789
124
- # (Optional) User pin for authentication with the specific slot. If not set, no authentication will
125
- # be used .
124
+ # (Optional) User pin for authentication with the specific slot. If not set, the sessions will not
125
+ # be logged in. It might prevent some operations to execute successfully on some tokens .
126
126
# user_pin = "123456"
127
127
# (Optional) Control whether missing public key operation (such as verifying signatures or asymmetric
128
128
# encryption) are fully performed in software.
Original file line number Diff line number Diff line change @@ -299,3 +299,13 @@ fn ts_pkcs11_cross() {
299
299
signature. clone ( ) ,
300
300
) ;
301
301
}
302
+
303
+ #[ test]
304
+ fn no_user_pin ( ) {
305
+ set_config ( "no_user_pin.toml" ) ;
306
+ // The service should still start, without the user pin.
307
+ reload_service ( ) ;
308
+
309
+ let mut client = TestClient :: new ( ) ;
310
+ let _ = client. ping ( ) . unwrap ( ) ;
311
+ }
Original file line number Diff line number Diff line change
1
+ [core_settings ]
2
+ # The CI already timestamps the logs
3
+ log_timestamp = false
4
+ log_error_details = true
5
+
6
+ # The container runs the Parsec service as root, so make sure we disable root
7
+ # checks.
8
+ allow_root = true
9
+
10
+ [listener ]
11
+ listener_type = " DomainSocket"
12
+ # The timeout needs to be smaller than the test client timeout (five seconds) as it is testing
13
+ # that the service does not hang for very big values of body or authentication length.
14
+ timeout = 3000 # in milliseconds
15
+ socket_path = " /tmp/parsec.sock"
16
+
17
+ [authenticator ]
18
+ auth_type = " Direct"
19
+
20
+ [[key_manager ]]
21
+ name = " on-disk-manager"
22
+ manager_type = " OnDisk"
23
+ store_path = " ./mappings"
24
+
25
+ [[provider ]]
26
+ provider_type = " Pkcs11"
27
+ key_info_manager = " on-disk-manager"
28
+ library_path = " /usr/local/lib/softhsm/libsofthsm2.so"
29
+ # The service should start without the user pin
30
+ # user_pin = "123456"
31
+ # The slot_number mandatory field is going to replace the following line with a valid number
32
+ # slot_number
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ pub struct Provider {
65
65
slot_number : Slot ,
66
66
software_public_operations : bool ,
67
67
allow_export : bool ,
68
+ need_login : bool ,
68
69
}
69
70
70
71
impl Provider {
@@ -80,9 +81,13 @@ impl Provider {
80
81
software_public_operations : bool ,
81
82
allow_export : bool ,
82
83
) -> Option < Provider > {
83
- if let Some ( pin) = user_pin {
84
+ let need_login = if let Some ( pin) = user_pin {
84
85
backend. set_pin ( slot_number, pin. expose_secret ( ) ) . ok ( ) ?;
85
- }
86
+ true
87
+ } else {
88
+ warn ! ( "No user pin has been set in the configuration file, sessions will not be logged in." ) ;
89
+ false
90
+ } ;
86
91
87
92
#[ allow( clippy:: mutex_atomic) ]
88
93
let pkcs11_provider = Provider {
@@ -92,6 +97,7 @@ impl Provider {
92
97
slot_number,
93
98
software_public_operations,
94
99
allow_export,
100
+ need_login,
95
101
} ;
96
102
{
97
103
let mut local_ids_handle = pkcs11_provider
@@ -197,7 +203,9 @@ impl Provider {
197
203
. open_session_no_callback ( self . slot_number , flags)
198
204
. map_err ( to_response_status) ?;
199
205
200
- session. login ( UserType :: User ) . map_err ( to_response_status) ?;
206
+ if self . need_login {
207
+ session. login ( UserType :: User ) . map_err ( to_response_status) ?;
208
+ }
201
209
202
210
Ok ( session)
203
211
}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ pub fn to_response_status(error: Error) -> ResponseStatus {
38
38
Error :: TryFromSlice ( e) => ResponseStatus :: from ( e) ,
39
39
Error :: NulError ( e) => ResponseStatus :: from ( e) ,
40
40
error => {
41
- error ! ( "Conversion of {} to PsaErrorCommunicationFailure" , error) ;
41
+ format_error ! ( "Conversion of error to PsaErrorCommunicationFailure" , error) ;
42
42
ResponseStatus :: PsaErrorCommunicationFailure
43
43
}
44
44
}
You can’t perform that action at this time.
0 commit comments