xref: /openbmc/docs/designs/management-console/VMI_Certificate_Exchange.md (revision f4febd002df578bad816239b70950f84ea4567e8)
188b4151bSRavi Teja# VMI Certificate Exchange
288b4151bSRavi Teja
3*f4febd00SPatrick WilliamsAuthor: Raviteja Bailapudi
488b4151bSRavi Teja
5*f4febd00SPatrick WilliamsOther contributors: Ratan Gupta
688b4151bSRavi Teja
7*f4febd00SPatrick WilliamsCreated: 07/10/2019
888b4151bSRavi Teja
988b4151bSRavi Teja## Glossary
10*f4febd00SPatrick Williams
1188b4151bSRavi Teja- HMC - Hardware Management Console : Management console for IBM enterprise
1288b4151bSRavi Teja  servers.
13*f4febd00SPatrick Williams- PHYP - Power Hypervisor : This orchestrates and manages system virtualization.
14*f4febd00SPatrick Williams- VMI - Virtual Management Interface : The interface facilitating communications
15*f4febd00SPatrick Williams  between HMC and PHYP embedded linux virtual machine.
1688b4151bSRavi Teja- KVM - Kernel Virtual Machine : Open source virtualization software
1788b4151bSRavi Teja
1888b4151bSRavi Teja## Problem Description
19*f4febd00SPatrick Williams
2088b4151bSRavi TejaOn enterprise POWER systems, the Hardware management console (HMC) needs to
2188b4151bSRavi Tejaestablish a secure connection to the Virtualization management interface (VMI)
2288b4151bSRavi Tejafor virtualization management.
2388b4151bSRavi Teja
2488b4151bSRavi TejaVMI is an embedded Linux VM created and run on PHYP which provides the
2588b4151bSRavi Tejavirtualization function.
2688b4151bSRavi Teja
27*f4febd00SPatrick WilliamsHMC requires client key, client.crt, and CA.crt to establish secure connection
28*f4febd00SPatrick Williamsto VMI.
2988b4151bSRavi Teja
30*f4febd00SPatrick WilliamsBMC needs to provide certificate exchange functionality to management console
31*f4febd00SPatrick Williamsdue to following reasons:
32*f4febd00SPatrick Williams
3388b4151bSRavi Teja- Host firmware (PHYP) does not have authentication mechanism.
34*f4febd00SPatrick Williams- VMI trusts that BMC has authenticated and verified the authenticity of any
35*f4febd00SPatrick Williams  client connected as there is a secure authenticated connection already exists
36*f4febd00SPatrick Williams  between HMC and BMC.
3788b4151bSRavi Teja
3888b4151bSRavi TejaManagement console needs an API through which it can send the CSR to VMI (CA)
39*f4febd00SPatrick Williamsand gets the signed certificate and the CA certificate from VMI. This design
40*f4febd00SPatrick Williamswill describe how certificates get exchanged between management console and VMI
4188b4151bSRavi Teja
42*f4febd00SPatrick WilliamsIBM systems can run both IBM specific host-firmware (PHYP) and Linux KVM. This
43*f4febd00SPatrick WilliamsAPI would be used only for the PHYP based machines.
4488b4151bSRavi Teja
4588b4151bSRavi TejaEnable and disable of this API would be controlled by the build time
4688b4151bSRavi Tejaconfigurable variable.
4788b4151bSRavi Teja
4888b4151bSRavi Teja## Background and References
49*f4febd00SPatrick Williams
5088b4151bSRavi Teja- VMI will be created and run on PHYP that will provide the virtualization
5188b4151bSRavi Teja  function.
52*f4febd00SPatrick Williams- When the VMI is powered on it generates a public-private key pair and a
53*f4febd00SPatrick Williams  self-signed root certificate is created using this key pair.
5488b4151bSRavi Teja- VMI acts as root CA only for VMI endpoints, its not an official CA and uses
5588b4151bSRavi Teja  its self-signed certificate to sign CSR from client.
5688b4151bSRavi Teja- HMC needs to establish secure connection to VMI to perform virtualization
5788b4151bSRavi Teja  management.
5888b4151bSRavi Teja
5988b4151bSRavi Teja## Requirements
60*f4febd00SPatrick Williams
6188b4151bSRavi TejaBMC will provide an interface for management console to exchange certificate
6288b4151bSRavi Tejainformation from VMI so that HMC can establish secure connection to VMI.
6388b4151bSRavi Teja
6488b4151bSRavi Teja## Proposed Design
6588b4151bSRavi Teja
66*f4febd00SPatrick WilliamsThe management console can send CSR string to VMI (CA) and get signed
67*f4febd00SPatrick Williamscertificate and Root CA certificate via proposed BMC interface.
6888b4151bSRavi Teja
69*f4febd00SPatrick WilliamsIn this interface perspective, the HTTP error code could be 4XX/5XX. It would be
70*f4febd00SPatrick Williamsmapped depending on the PLDM error response.
71*f4febd00SPatrick Williams
72*f4febd00SPatrick WilliamsHMC can query BMC state and use this API to initiate certificate exchange.If HMC
73*f4febd00SPatrick Williamsruns this command before PHYP boots, PLDM command returns error If PLDM command
74*f4febd00SPatrick Williamsthrows an error, that would be mapped to Internal server Error (500).
7588b4151bSRavi Teja
7688b4151bSRavi Teja### Design Flow
77*f4febd00SPatrick Williams
7888b4151bSRavi Teja```ascii
7988b4151bSRavi Teja    +------------+        +--------+            +--------+
8088b4151bSRavi Teja    |    HMC     |        |  BMC   |            |  VMI   |
8188b4151bSRavi Teja    |  (client)  |        |        |            |  (CA)  |
8288b4151bSRavi Teja    +-----+------+        +----+---+            +---+----+
8388b4151bSRavi Teja          |                    |                    |
8488b4151bSRavi Teja          |                    |                    |
8588b4151bSRavi Teja          +------------------->+                    |
8688b4151bSRavi Teja          | VMI Network info   |                    |
8788b4151bSRavi Teja          +<-------------------+                    |
8888b4151bSRavi Teja          |                    |                    |
8988b4151bSRavi Tejaclient.key|                    |                    |
9088b4151bSRavi Tejaclient.csr     SignCSR()       | pldm call to host  |
9188b4151bSRavi Teja          +------------------->+------------------->|
9288b4151bSRavi Teja          |                    |                    |  Sign CSR
9388b4151bSRavi Teja          | SignCSR() response | pldm response from host
9488b4151bSRavi Teja          +<-------------------+<-------------------|
9588b4151bSRavi Teja          |                    |                    |
9688b4151bSRavi Teja  Client.crt                   |                    |
9788b4151bSRavi Teja  CA.crt                       |                    |
9888b4151bSRavi Teja          |                    |                    |
9988b4151bSRavi Teja          |                    |                    |
10088b4151bSRavi Teja          |                    |                    |
10188b4151bSRavi Teja          |                    |                    |
10288b4151bSRavi Teja          +                    +                    +
10388b4151bSRavi Teja
10488b4151bSRavi Teja```
105*f4febd00SPatrick Williams
10688b4151bSRavi Teja### VMI certificate exchange
107*f4febd00SPatrick Williams
10888b4151bSRavi TejaManagement console should use the below REST commands to exchange certificates
10988b4151bSRavi Tejawith VMI
11088b4151bSRavi Teja
11188b4151bSRavi Teja#### Get Signed certificate:
112*f4febd00SPatrick Williams
11388b4151bSRavi TejaREST command to get signed client certificate from VMI
11488b4151bSRavi Teja
11588b4151bSRavi TejaRequest:
116*f4febd00SPatrick Williams
11788b4151bSRavi Teja```bash
11888b4151bSRavi Tejacurl -k -H "X-Auth-Token:  <token>" -X POST "Content-Type: application/json" -d
11988b4151bSRavi Teja  '{"CsrString":"<CSR string>"}' https://{BMC_IP}/ibm/v1/Host/Actions/SignCSR
12088b4151bSRavi Teja```
12188b4151bSRavi Teja
122*f4febd00SPatrick WilliamsResponse: This will return the certificate string which contains signed client
12388b4151bSRavi Tejacertificate
12488b4151bSRavi Teja
12588b4151bSRavi Teja```
12688b4151bSRavi Teja {
12788b4151bSRavi Teja   “Certificate”: "<certificate string>"
12888b4151bSRavi Teja }
12988b4151bSRavi Teja
13088b4151bSRavi Teja```
131*f4febd00SPatrick Williams
13288b4151bSRavi Teja#### Get Root certificate:
133*f4febd00SPatrick Williams
13488b4151bSRavi TejaREST command to get VMI root certificate
13588b4151bSRavi Teja
13688b4151bSRavi TejaRequest:
137*f4febd00SPatrick Williams
13888b4151bSRavi Teja```bash
13988b4151bSRavi Tejacurl -k -H "X-Auth-Token:  <token>" -X GET http://{BMC_IP}/ibm/v1/Host/Certificate/root
14088b4151bSRavi Teja```
14188b4151bSRavi Teja
142*f4febd00SPatrick WilliamsResponse: This will return the certificate string which contains and root CA
143*f4febd00SPatrick Williamscertificate.
14488b4151bSRavi Teja
14588b4151bSRavi Teja```
14688b4151bSRavi Teja {
14788b4151bSRavi Teja   “Certificate”: "<certificate string>"
14888b4151bSRavi Teja }
14988b4151bSRavi Teja
15088b4151bSRavi Teja```
151*f4febd00SPatrick Williams
15288b4151bSRavi TejaThis interface returns HTTP error codes 5XX/4XX in failure cases
15388b4151bSRavi Teja
15488b4151bSRavi Teja## Alternatives considered:
15588b4151bSRavi Teja
15688b4151bSRavi TejaHave gone through existing BMC certificate management infrastructure if we can
15788b4151bSRavi Tejaextend for this use case.
15888b4151bSRavi Teja
15988b4151bSRavi Teja### Current flow for generating and installing Certificates (CSR Based):
16088b4151bSRavi Teja
161*f4febd00SPatrick Williams- Certificate Signing Request CSR is a message sent from an applicant to a
16288b4151bSRavi Teja  certificate authority in order to apply for a digital identity certificate.
163*f4febd00SPatrick Williams- The user calls CSR interface BMC creates new private key and CSR Certificate
16488b4151bSRavi Teja  File
165*f4febd00SPatrick Williams- CSR certificate is passed onto the CA to sign the certificate and then upload
16688b4151bSRavi Teja  CSR signed certificate and install the certificate.
16788b4151bSRavi Teja
16888b4151bSRavi Teja### Note
16988b4151bSRavi Teja
170*f4febd00SPatrick Williams- Our existing BMC certificate manager/service have interfaces to generate CSR,
171*f4febd00SPatrick Williams  upload certificates and other interfaces to manage
172*f4febd00SPatrick Williams  certificates(replace,delete..etc).
173*f4febd00SPatrick Williams- In VMI certificate exchange, requirement for BMC is to provide an interface
174*f4febd00SPatrick Williams  for management console to get CSR certificate signed by VMI (CA).
175*f4febd00SPatrick Williams- We don’t have any existing certificate manager interface to forward CSR
17688b4151bSRavi Teja  request to CA to get signed by CA.
177*f4febd00SPatrick Williams- Here proposal is to have SignCSR() interface which accepts CSR string and
17888b4151bSRavi Teja  return signed certificate and Root CA certificate.
179*f4febd00SPatrick Williams- This requirement is out of scope for existing certificate manager so proposing
18088b4151bSRavi Teja  SignCSR interface as management console specific interface.
18188b4151bSRavi Teja
18288b4151bSRavi Teja### Alternate Design
183*f4febd00SPatrick Williams
18488b4151bSRavi Teja```ascii
18588b4151bSRavi Teja    +------------+        +--------+            +--------+
18688b4151bSRavi Teja    |    HMC     |        |  BMC   |            |  VMI   |
18788b4151bSRavi Teja    |  (client)  |        |        |            |  PHYP  |
18888b4151bSRavi Teja    +-----+------+        +----+---+            +---+----+
18988b4151bSRavi Teja          |                    |                    |
19088b4151bSRavi Teja          |                    |                    |
19188b4151bSRavi Teja          +------------------->+                    |
19288b4151bSRavi Teja          | VMI Network info   |                    |
19388b4151bSRavi Teja          +<-------------------+                    |
19488b4151bSRavi Teja          |                                         |
19588b4151bSRavi Teja          |                SSL tunnel               |
19688b4151bSRavi Teja          +---------------------------------------->|
19788b4151bSRavi Teja          |              Verify Password            |Nets
19888b4151bSRavi Teja          +---------------------------------------->|
19988b4151bSRavi Teja          |                                         |
20088b4151bSRavi Teja          |                  pldm                   |pldm call to authenticate
20188b4151bSRavi Teja          +<-------------------+<-------------------|
20288b4151bSRavi Teja          |                    |                    |
20388b4151bSRavi Teja          |                   pam                   |
20488b4151bSRavi Teja          |              authentication             |
20588b4151bSRavi Teja          |                    +------------------->|
20688b4151bSRavi Teja          |                                         |
20788b4151bSRavi Teja          |        session established              |
20888b4151bSRavi Teja          |<--------------------------------------->|
20988b4151bSRavi Teja
21088b4151bSRavi Teja```
211*f4febd00SPatrick Williams
212*f4febd00SPatrick Williams- In this alternate design, Management console establishes connection to VMI and
213*f4febd00SPatrick Williams  sends Verify Password command to authenticate user to establish secure
214*f4febd00SPatrick Williams  session.
215*f4febd00SPatrick Williams- VMI does not have authentication method, so VMI needs to use BMC
216*f4febd00SPatrick Williams  authentication method over PLDM.
217*f4febd00SPatrick Williams- There are security concerns if raw password is getting sent over PLDM in clear
218*f4febd00SPatrick Williams  text over LPC, so this design ruled out.
21988b4151bSRavi Teja
22088b4151bSRavi Teja## Impacts
221*f4febd00SPatrick Williams
222*f4febd00SPatrick Williams- Create new interface GetRootCertificate in webserver which reads root
223*f4febd00SPatrick Williams  certificate from '/var/lib/bmcweb/RootCert' file.This API can handle muptiple
224*f4febd00SPatrick Williams  requests at the sametime.
22588b4151bSRavi Teja- PLDM gets root certificate as soon as VMI boots and it writes to
22688b4151bSRavi Teja  '/var/lib/bmcweb/RootCert'.
227*f4febd00SPatrick Williams- Implement D-Bus interface to create dbus object for each signCSR so that
228*f4febd00SPatrick Williams  multiple requests can work at the sametime. D-bus service:
229*f4febd00SPatrick Williams  xyz.openbmc_project.Certs.ca.authority.Manager Object path :
230*f4febd00SPatrick Williams  /xyz/openbmc_project/certs/ca Interface : xyz.openbmc_project.Certs.Authority
23188b4151bSRavi Teja  Method : SignCSR
23288b4151bSRavi Teja- Dbus object contains CSR,ClientCertificate and Status properties.
233*f4febd00SPatrick Williams- PLDM looks for interface added signal for each object created and reads CSR
234*f4febd00SPatrick Williams  property for CSR string and forwards this CSR string to VMI for signing this
235*f4febd00SPatrick Williams  CSR.
236*f4febd00SPatrick Williams- Once PLDM on BMC gets the client certificate from VMI, it updates the
237*f4febd00SPatrick Williams  ClientCertificate D-bus property and updates the Status property to Complete
238*f4febd00SPatrick Williams  in the Dbus object.
239*f4febd00SPatrick Williams- Create new interface SignCSR in webserver which takes CSR string as input and
240*f4febd00SPatrick Williams  returns certificate string.This interface calls SignCSR dbus method and looks
241*f4febd00SPatrick Williams  for Status property changed signal to verify status.Reads ClientCertificate
242*f4febd00SPatrick Williams  property content and return certificate string.
243*f4febd00SPatrick Williams- On completion of serving the sign CSR request, respective dbus object will be
244*f4febd00SPatrick Williams  deleted before returning certificate string to client.
245*f4febd00SPatrick Williams- BMC is passthrough which allows certificate exchange between VMI and HMC. BMC
246*f4febd00SPatrick Williams  does not store or parse these certificates.
247*f4febd00SPatrick Williams- Build time configure variable defined to control enable and disable of this
248*f4febd00SPatrick Williams  API in webserver. It is required only for IBM systems with IBM specific
249*f4febd00SPatrick Williams  host-firmware (PHYP)
25088b4151bSRavi Teja
25188b4151bSRavi Teja## Testing
252*f4febd00SPatrick Williams
25388b4151bSRavi Teja- Test the interface command from a management console and verify if certificate
25488b4151bSRavi Teja  exchange worked as expected and verify if management console able to establish
25588b4151bSRavi Teja  secure connection to VMI.
25688b4151bSRavi Teja
25788b4151bSRavi Teja- Certificate exchange fails in the following scenarios
25888b4151bSRavi Teja
259*f4febd00SPatrick Williams  - If PHYP is not up
260*f4febd00SPatrick Williams  - If PHYP throws error for certificate validation. This interface returns
261*f4febd00SPatrick Williams    appropriate HTTP error code (4XX/5XX) based on type of error.
262*f4febd00SPatrick Williams
263*f4febd00SPatrick Williams- If there are issues like certificate expiry, revocation, incorrect date/time
264*f4febd00SPatrick Williams  and incorrect certificates, then HMC fails to establish connection to VMI.
265