-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update JSON handling for TLS keys #890
Comments
There are also other problems here. It seems the TLS identity version is hardcoded to 0 in the JSON TLS handling: https://github.com/linux-nvme/libnvme/blob/master/src/nvme/json.c#L52 |
The specs states under
The current code is actually doing this, it outputs the retained PSK to the JSON file after a successful # nvme check-tls-key -i -I 1 -c nqn.io-1 -n nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36 -d NVMeTLSkey-1:01:PMmRzMi+sRVtOSc6qpz8DaNszOufkp/+P1pp+M6r6/cGUjM9:
# nvme connect -t tcp -a 192.168.154.148 -s 4420 -q nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36 -n nqn.io-1 --tls --tls_key=811559380 -O
connecting to device: nvme1
[
{
"hostnqn":"nqn.2014-08.org.nvmexpress:uuid:2cd2c43b-a90a-45c1-a8cd-86b33ab273b6",
"hostid":"2cd2c43b-a90a-45c1-a8cd-86b33ab273b6",
"subsystems":[
{
"nqn":"nqn.io-1",
"ports":[
{
"transport":"tcp",
"traddr":"192.168.154.144",
"trsvcid":"4421",
"dhchap_key":"none"
},
{
"transport":"tcp",
"traddr":"192.168.154.144",
"trsvcid":"4420",
"dhchap_key":"none"
}
]
}
]
},
{
"hostnqn":"nqn.2014-08.org.nvmexpress:uuid:2cd2c43b-a90a-45c1-a8cd-86b33ab273b5",
"hostid":"2cd2c43b-a90a-45c1-a8cd-86b33ab273b5",
"subsystems":[
{
"nqn":"nqn.io-1",
"ports":[
{
"transport":"tcp",
"traddr":"192.168.154.144",
"trsvcid":"4421",
"dhchap_key":"none"
},
{
"transport":"tcp",
"traddr":"192.168.154.144",
"host_iface":"enp52s0f3u1",
"trsvcid":"4420",
"dhchap_key":"none"
}
]
}
]
},
{
"hostnqn":"nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36",
"hostid":"befdec4c-2234-11b2-a85c-ca77c773af36",
"subsystems":[
{
"nqn":"nqn.io-1",
"ports":[
{
"transport":"tcp",
"traddr":"192.168.154.144",
"trsvcid":"4421",
"dhchap_key":"none"
}
]
}
]
},
{
"hostnqn":"nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36",
"hostid":"2cd2c43b-a90a-45c1-a8cd-86b33ab273b6",
"subsystems":[
{
"nqn":"nqn.io-1",
"ports":[
{
"transport":"tcp",
"traddr":"192.168.154.148",
"trsvcid":"4420",
"dhchap_key":"none",
"tls":true,
"tls_key":"NVMeTLSkey-1:01:Hhc5sFjwSZ6w5hPY19tqprajYtuYci3tN+Z2wGViDk3rpSR+:"
}
]
}
]
}
] |
That means the PSK interchange format contains the configured PSK and thus as reported we should not store the retained PSK. Also did a bit of digging in the RFCs on HMACs
to figure out what we actually need to store in the JSON file. The PSK interchange format tells us which version (currently hard coded to 1 and which HMAC is used. But let's make this future proof (see linux-nvme/nvme-cli#1669). |
I can't really follow here, where is this Anyway, it is technically impossible to produce a 'correct' JSON output file for the connect case when the key is already in the keystore, because we only store retained keys in the store. The only way to generate the 'correct' JSON output is when the configured key is present during the connect command. But this leads to the problem that key is likely to be stored in the shell history. |
'tls_configured_key' is the key specified on the nvme-cli commandline via '--tls_key'. Which makes it a 'retained' key in Spec parlance. |
As mentioned, I really want to avoid having to specify the TLS key in interchange format on the commandline. That will allow any unprivileged process to read the key data and cause a security nightmare. |
So, my recommendation would be this:
|
But that means we're doing things correctly already, and nothing is to be done. |
Yep, this is what I also thought. Some parts of the refactoring/extension in #894 makes sense. Maybe even the |
Just verfied that Though when loading the JSON file, the key listed under |
As per Hannes:
JSON handling needs to be updated with the latest TLS changes upstream, which introduced a 'tls_configured_key' in addition to the existing 'tls_key' to differentiate between the TLS key used by the current connection (the 'tls_key' attribute) and the TLS key specified on the command line (the 'tls_configured_key' attribute).
With that change we can format the JSON configuration correctly, and only specify the TLS key in the JSON configuration if it had been configured on the command line.
The text was updated successfully, but these errors were encountered: