File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,23 +126,27 @@ impl OnboardRpc for OnboardHandler {
126126
127127 async fn onboard ( self , request : OnboardRequest ) -> Result < OnboardResponse > {
128128 validate_onboarding_domain ( & request. domain ) ?;
129+ let _bootstrap_guard = self . state . bootstrap_lock . lock ( ) . await ;
130+ let cfg = & self . state . config ;
131+ if cfg. root_ca_key ( ) . exists ( ) || cfg. k256_key ( ) . exists ( ) {
132+ bail ! ( "KMS has already been onboarded" ) ;
133+ }
129134 let source_url = request. source_url . trim_end_matches ( '/' ) . to_string ( ) ;
130135 let source_url = if source_url. ends_with ( "/prpc" ) {
131136 source_url
132137 } else {
133138 format ! ( "{source_url}/prpc" )
134139 } ;
135140 let keys = Keys :: onboard (
136- & self . state . config ,
141+ cfg ,
137142 & source_url,
138143 & request. domain ,
139144 self . state . attestation_verifier . clone ( ) ,
140145 )
141146 . await
142147 . context ( "Failed to onboard" ) ?;
143148 let k256_pubkey = keys. k256_key . verifying_key ( ) . to_sec1_bytes ( ) . to_vec ( ) ;
144- keys. store ( & self . state . config )
145- . context ( "Failed to store keys" ) ?;
149+ keys. store ( cfg) . context ( "Failed to store keys" ) ?;
146150 Ok ( OnboardResponse { k256_pubkey } )
147151 }
148152
You can’t perform that action at this time.
0 commit comments