Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

File permissions incorrect #2

Open
thernstig opened this issue Jul 18, 2018 · 2 comments
Open

File permissions incorrect #2

thernstig opened this issue Jul 18, 2018 · 2 comments

Comments

@thernstig
Copy link

See https://docs.docker.com/engine/security/https/#create-a-ca-server-and-client-keys-with-openssl

generate_client_certs.yml and generate_server_certs.yml does not set the same permission as specified in the above link.

0400 should be set on all keys
0444 should be set on all certs

As such, both .yml files need to split the file permission step into two tasks to handle this.

@bk203
Copy link

bk203 commented Jul 20, 2018

So like this, if i correctly understand the problem:

generate_client_certs.yml

- name: Set file permissions for keys
  file:
    path: "{{ dds_client_cert_path }}/{{ item }}"
    mode: 0400
  with_items:
    - key.pem

- name: Set file permissions for certificates
  file:
    path: "{{ dds_client_cert_path }}/{{ item }}"
    mode: 0444
  with_items:
    - ca.pem
    - cert.pem

generate_server_certs.yml

- name: Set file permissions for keys
  file:
    path: "{{ dds_server_cert_path }}/{{ item }}"
    mode: 0400
  with_items:
    - server-key.pem

- name: Set file permissions for certificates
  file:
    path: "{{ dds_server_cert_path }}/{{ item }}"
    mode: 0444
  with_items:
    - ca.pem
    - server-cert.pem

@thernstig
Copy link
Author

thernstig commented Jul 23, 2018

@msmit1993 Correct, so not a big change. With the addition that ca-key.pem should possibly also get 0400 in main.yml, as I suppose one wants to save that file as well to create new CSR's in the future.

It is quite bad as it is now that key.pem gets 0444, that is definitely a problem.

bk203 added a commit to bk203/role-secure-docker-daemon that referenced this issue Jul 23, 2018
Response to issue: File permissions incorrect ansible#2

* Split permission job into two jobs
* Set key files permission to 400
* Set certificate files to 444

Changes according to official Docker documentation  https://docs.docker.com/engine/security/https/#create-a-ca-server-and-client-keys-with-openssl
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants