summaryrefslogtreecommitdiff
path: root/src/conf_mode/https.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-08-15 01:03:06 +0700
committerGitHub <noreply@github.com>2019-08-15 01:03:06 +0700
commit58c5a7e668d0131de50e6f9711f029f9ff4a02ab (patch)
tree9954f9f8d20032a26d6ae0d5601693c80fd01771 /src/conf_mode/https.py
parent8d1e768a6f3285ed717f588f356db9340871b043 (diff)
parente304e91a781f79c1e12bb2a7f806a0015bf039e3 (diff)
downloadvyos-1x-58c5a7e668d0131de50e6f9711f029f9ff4a02ab.tar.gz
vyos-1x-58c5a7e668d0131de50e6f9711f029f9ff4a02ab.zip
Merge pull request #103 from jestabro/service-https
[service https] T1443: add self-signed TLS certificate
Diffstat (limited to 'src/conf_mode/https.py')
-rwxr-xr-xsrc/conf_mode/https.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/conf_mode/https.py b/src/conf_mode/https.py
index e1e81eef1..289eacf69 100755
--- a/src/conf_mode/https.py
+++ b/src/conf_mode/https.py
@@ -21,6 +21,7 @@ import os
import jinja2
+import vyos.defaults
from vyos.config import Config
from vyos import ConfigError
@@ -45,11 +46,16 @@ server {
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
+
+{% if vyos_cert %}
+ include {{ vyos_cert.conf }};
+{% else %}
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
include snippets/snakeoil.conf;
+{% endif %}
{% for l_addr in listen_address %}
server_name {{ l_addr }};
@@ -75,16 +81,8 @@ server {
}
"""
-default_config_data = {
- 'listen_address' : [ '127.0.0.1' ]
-}
-
-default_api_config_data = {
- 'port' : '8080',
-}
-
def get_config():
- https = default_config_data
+ https = vyos.defaults.https_data
conf = Config()
if not conf.exists('service https'):
return None
@@ -95,8 +93,12 @@ def get_config():
addrs = conf.return_values('listen-address')
https['listen_address'] = addrs[:]
+ if conf.exists('certificates'):
+ if conf.exists('certificates system-generated-certificate'):
+ https['vyos_cert'] = vyos.defaults.vyos_cert_data
+
if conf.exists('api'):
- https['api'] = default_api_config_data
+ https['api'] = vyos.defaults.api_data
if conf.exists('api port'):
port = conf.return_value('api port')