Skip to content

Commit 4e7bd81

Browse files
authored
Merge pull request #148 from TheOneAboveAllTitan/issues/147
[x509] Added dedicated file mode for generated x509 certificates #147
2 parents 75a77ef + 10e4e8d commit 4e7bd81

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

netjsonconfig/backends/openvpn/openvpn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ...schema import DEFAULT_FILE_MODE
1+
from ...schema import X509_FILE_MODE
22
from ..base.backend import BaseBackend
33
from . import converters
44
from .parser import OpenVpnParser, config_suffix, vpn_pattern
@@ -121,15 +121,15 @@ def _auto_client_files(cls, client, ca_path=None, ca_contents=None, cert_path=No
121121
client['ca'] = ca_path
122122
files.append(dict(path=ca_path,
123123
contents=ca_contents,
124-
mode=DEFAULT_FILE_MODE))
124+
mode=X509_FILE_MODE))
125125
if cert_path and cert_contents:
126126
client['cert'] = cert_path
127127
files.append(dict(path=cert_path,
128128
contents=cert_contents,
129-
mode=DEFAULT_FILE_MODE))
129+
mode=X509_FILE_MODE))
130130
if key_path and key_contents:
131131
client['key'] = key_path
132132
files.append(dict(path=key_path,
133133
contents=key_contents,
134-
mode=DEFAULT_FILE_MODE,))
134+
mode=X509_FILE_MODE,))
135135
return files

netjsonconfig/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .countries import countries
88

99
DEFAULT_FILE_MODE = '0644'
10+
X509_FILE_MODE = '0600'
1011
MAC_PATTERN = '([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})'
1112
MAC_PATTERN_BLANK = '^({0}|)$'.format(MAC_PATTERN)
1213

tests/openvpn/test_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,17 +586,17 @@ def test_auto_client_complex(self):
586586
# ---------- files ---------- #
587587
588588
# path: {{ca_path_1}}
589-
# mode: 0644
589+
# mode: 0600
590590
591591
{{ca_contents_1}}
592592
593593
# path: {{cert_path_1}}
594-
# mode: 0644
594+
# mode: 0600
595595
596596
{{cert_contents_1}}
597597
598598
# path: {{key_path_1}}
599-
# mode: 0644
599+
# mode: 0600
600600
601601
{{key_contents_1}}
602602

tests/openwisp/test_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ class TestBackend(unittest.TestCase, _TabsMixin):
107107
"files": [
108108
{
109109
"path": "/openvpn/x509/ca_1_service.pem",
110-
"mode": "0644",
110+
"mode": "0600",
111111
"contents": "-----BEGIN CERTIFICATE-----\ntest\n-----END CERTIFICATE-----\n" # noqa
112112
},
113113
{
114114
"path": "/openvpn/x509/l2vpn_client_2693.pem",
115-
"mode": "0644",
115+
"mode": "0600",
116116
"contents": "-----BEGIN CERTIFICATE-----\ntest==\n-----END CERTIFICATE-----\n-----BEGIN RSA PRIVATE KEY-----\ntest\n-----END RSA PRIVATE KEY-----\n" # noqa
117117
}
118118
]

0 commit comments

Comments
 (0)