summaryrefslogtreecommitdiffstats
path: root/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb')
-rw-r--r--recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb50
1 files changed, 50 insertions, 0 deletions
diff --git a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb b/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb
new file mode 100644
index 0000000..5debc19
--- /dev/null
+++ b/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb
@@ -0,0 +1,50 @@
1SUMMARY = "Credentials for implicit provisioning with CA certificate"
2SECTION = "base"
3LICENSE = "MPL-2.0"
4LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
5
6DEPENDS = "aktualizr aktualizr-native"
7
8SRC_URI = " \
9 file://ca.cnf \
10 "
11
12require credentials.inc
13
14export SOTA_CACERT_PATH
15export SOTA_CAKEY_PATH
16
17do_install() {
18 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
19 if [ -z ${SOTA_CACERT_PATH} ]; then
20 SOTA_CACERT_PATH=${DEPLOY_DIR_IMAGE}/CA/cacert.pem
21 SOTA_CAKEY_PATH=${DEPLOY_DIR_IMAGE}/CA/ca.private.pem
22 mkdir -p ${DEPLOY_DIR_IMAGE}/CA
23 bbwarn "SOTA_CACERT_PATH is not specified, use default one at $SOTA_CACERT_PATH"
24
25 if [ ! -f ${SOTA_CACERT_PATH} ]; then
26 bbwarn "${SOTA_CACERT_PATH} does not exist, generate a new CA"
27 SOTA_CACERT_DIR_PATH="$(dirname "$SOTA_CACERT_PATH")"
28 openssl genrsa -out ${SOTA_CACERT_DIR_PATH}/ca.private.pem 4096
29 openssl req -key ${SOTA_CACERT_DIR_PATH}/ca.private.pem -new -x509 -days 7300 -out ${SOTA_CACERT_PATH} -subj "/C=DE/ST=Berlin/O=Reis und Kichererbsen e.V/commonName=meta-updater" -batch -config ${WORKDIR}/ca.cnf -extensions cacert
30 bbwarn "${SOTA_CACERT_PATH} has been created, you'll need to upload it to the server"
31 fi
32 fi
33
34 if [ -z ${SOTA_CAKEY_PATH} ]; then
35 bberror "SOTA_CAKEY_PATH should be set when using implicit provisioning"
36 fi
37
38 install -m 0700 -d ${D}${localstatedir}/sota
39 aktualizr_cert_provider --credentials ${SOTA_PACKED_CREDENTIALS} \
40 --device-ca ${SOTA_CACERT_PATH} \
41 --device-ca-key ${SOTA_CAKEY_PATH} \
42 --root-ca \
43 --server-url \
44 --local ${D} \
45 --config ${STAGING_DIR_HOST}${libdir}/sota/sota_implicit_prov_ca.toml
46 fi
47}
48
49FILES_${PN} = " \
50 ${localstatedir}/sota/*"