-
Notifications
You must be signed in to change notification settings - Fork 32
Description
There's a business requirement to allow a Node to keep the same public key over a shutdown/startup cycle.
We'll do this by having a newly-installed Node pick its own key pair and store it in the database; then assume it on startup each time. (Another card (GH-623) will allow the user to specify --new-public-key on or --new-public-key off on the command line; but that's not this card.)
-
CryptDERealhas two important fields:
encryption_secret_key
signing_secret_key
You should be able to reconstitute an entireCryptDERealfrom just these two fields. -
These two fields should be stored in the
CONFIGtable in the database. Since they're really different parts of the same data object, there's a good argument for storing both fields in the same row. Suggestion: Get the binary data from each secret key, Base64-encode it into a string, and store both strings in theVALUEcolumn of theCONFIGtable, separated by some character that's not used in the Base64 encoding, like space or comma. -
Be sure to save these fields as encrypted: they're secret keys.
-
This will require a database migration. Migrate from version 10 to version 11, adding a row to the
CONFIGtable. Look atmigration_0_to_1.rsfor an example. -
Add
From<String>andInto<String>methods toCryptDEand implement them in bothCryptDERealandCryptDENull. Add a pair of methods toPersistentConfigurationfor reading and writingCryptDEs to the database, using the newFromandIntoimplementations. -
Definitely write the main
CryptDEto the database. You can probably get away without writing the aliasCryptDEto the database. The aliasCryptDEshouldn't need to maintain its value between Node runs, only between the time a request is sent and the time the response arrives. -
The main
CryptDEis established inActorSystemFactoryTools, by thecryptdes()method. You'll want to modify this method to takeBootstrapperConfigandPersistentConfigurationreferences and call the newPersistentConfiguration::cryptde()method with the database password (if any) from theBootstrapperConfig. If it returnsSome(cryptde), use that one. If it returns None, generate a new one withCryptDEReal::default()and callPersistentConfiguration::set_cryptde()with it. -
Edge cases:
- Maybe
BootstrapperConfig::db_password_optisNone. In that case, always generate a new public key, because you can't read or write an encrypted value without a password.
- Maybe
Metadata
Metadata
Assignees
Labels
Type
Projects
Status