summaryrefslogtreecommitdiffstats
path: root/install/share/csrgen/templates/openssl_base.tmpl
blob: 22b16862e88eb44c4176ee9c4580188f5b240854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{% raw -%}
{% import "openssl_macros.tmpl" as openssl -%}
{%- endraw %}
#!/bin/bash -e

if [[ $# -lt 2 ]]; then
echo "Usage: $0 <outfile> <keyfile> <other openssl arguments>"
echo "Called as: $0 $@"
exit 1
fi

CONFIG="$(mktemp)"
CSR="$1"
KEYFILE="$2"
shift; shift

echo \
{% raw %}{% filter quote %}{% endraw -%}
[ req ]
prompt = no
encrypt_key = no

{{ parameters|join('\n') }}
{% raw %}{% set rendered_extensions -%}{% endraw %}
{{ extensions|join('\n') }}
{% raw -%}
{%- endset -%}
{% if rendered_extensions -%}
req_extensions = {% call openssl.section() %}{{ rendered_extensions }}{% endcall %}
{% endif %}
{{ openssl.openssl_sections|join('\n\n') }}
{% endfilter %}{%- endraw %} > "$CONFIG"

openssl req -new -config "$CONFIG" -out "$CSR" -key "$KEYFILE" "$@"
rm "$CONFIG"