Skip to content
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

PKI CA chain == CA certificate? #2075

Closed
prudnitskiy opened this issue Nov 8, 2016 · 7 comments
Closed

PKI CA chain == CA certificate? #2075

prudnitskiy opened this issue Nov 8, 2016 · 7 comments

Comments

@prudnitskiy
Copy link

Hello all!

I built a two-level PKI (root PKI and intermediate PKI signed by root PKI) by instructions found here and here. When I try to get ca_chain from intermediate PKI I can see only a CA certificate from that PKI (but not all other certificates in chain). Is it a normal behaviour?

Vault version is 0.6.2

@jefferai
Copy link
Member

jefferai commented Nov 8, 2016

Yes -- if you want the full CA chain output, you should upload the root cert along with the signed intermediate CA cert when you use set-signed .

@frlod
Copy link

frlod commented Dec 18, 2017

@jefferai Would this work if I provide a pem bundle (private key + CA chain) when submitting an already-signed intermediate certificate using the POST pki/config/ca path?

I would also like the whole ca_chain to be returned, but the difference is that I do not generate the intermediate key with vault, but I generate it and sign it with an outside root, and then submit it into vault.

Thanks!

@bhperry
Copy link

bhperry commented Feb 13, 2018

@frlod Yes that works. Just tested it, and vault is able to correctly parse out the issuing_ca from the chain, while also returning the full ca_chain cert that was provided.

@cyberwave
Copy link

hello everyone! I want to learn about PKI and CA. Who has the relevant book recommendation?

@chrishoffman
Copy link
Contributor

@cyberwave If you are looking for some book recommendations, the vault mailing list would be a better resource to ask the community. See https://groups.google.com/forum/#!forum/vault-tool.

@aantono
Copy link
Contributor

aantono commented Jul 8, 2019

@jefferai Is there any way a more detailed step-by-step instructions can be provided? I've been searching Google Groups and internet for examples, but nothing came up as to how to add the Root Public Certificate component to be returned when asking for a ca_chain! :(

@notanaverageman
Copy link

You can get the root certificate from /v1/pki/cert/ca and append it to the signed intermediate certificate with a new line.
I use the following Ansible script:

- name: "Enable PKI secret engine."
  uri:
    url: "https://{{ vault.ingress.host_path }}/v1/sys/mounts/pki_{{ item }}"
    method: POST
    headers:
      X-Vault-Token: "{{ vault_root_token }}"
    body_format: json
    body:
      type: pki
      config:
        max_lease_ttl: "43800h" # 5 years
    status_code:
      - 200
      - 204

- name: "Generate intermediate certificate."
  uri:
    url: "https://{{ vault.ingress.host_path }}/v1/pki_{{ item }}/intermediate/generate/internal"
    method: POST
    return_content: yes
    headers:
      X-Vault-Token: "{{ vault_root_token }}"
    body_format: json
    body:
      common_name: "{{ vault.ingress.host_path }} Intermediate Authority: {{ item }}"
    status_code:
      - 200
      - 204
  register: intermediate_csr_result

- name: "Sign the intermediate certificate."
  uri:
    url: "https://{{ vault.ingress.host_path }}/v1/pki/root/sign-intermediate"
    method: POST
    return_content: yes
    headers:
      X-Vault-Token: "{{ vault_root_token }}"
    body_format: json
    body:
      csr: "{{ intermediate_csr_result.json.data.csr }}"
      format: pem_bundle
      ttl: "43800h"
    status_code:
      - 200
      - 204
  register: sign_intermediate_result

- name: "Get the root certificate."
  uri:
    url: "https://{{ vault.ingress.host_path }}/v1/pki/cert/ca"
    method: GET
    return_content: yes
    headers:
      X-Vault-Token: "{{ vault_root_token }}"
    body_format: json
    status_code:
      - 200
      - 204
  register: root_certificate_result

- name: "Import the signed intermediate certificate."
  uri:
    url: "https://{{ vault.ingress.host_path }}/v1/pki_{{ item }}/intermediate/set-signed"
    method: POST
    return_content: yes
    headers:
      X-Vault-Token: "{{ vault_root_token }}"
    body_format: json
    body:
      certificate: "{{ sign_intermediate_result.json.data.certificate }}\n{{ root_certificate_result.json.data.certificate }}"
    status_code:
      - 200
      - 204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants