• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-mcu / 1980936255

01 Jul 2025 12:13PM UTC coverage: 57.289% (-0.1%) from 57.395%
1980936255

push

gitlab-ci

web-flow
Merge pull request #210 from elkoniu/add-2nd-cert

feat: Add backup root cert to Zephyr certs chain

6 of 9 new or added lines in 2 files covered. (66.67%)

5 existing lines in 2 files now uncovered.

2303 of 4020 relevant lines covered (57.29%)

70.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/src/platform/certs/zephyr/certs.c
1
/**
2
 * @file      certs.c
3
 * @brief     Mender MCU Certificate for zephyr
4
 *
5
 * Copyright Northern.tech AS
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19

20
#include <stddef.h> /* size_t */
21
#include <zephyr/net/tls_credentials.h>
22

23
#include "certs.h"
24
#include "log.h"
25
#include <errno.h>
26

27
static const unsigned char dormant_certificate_a[] = {
28
#include "dormant_a.cer.inc"
29
};
30

31
static const unsigned char dormant_certificate_b[] = {
32
#include "dormant_b.cer.inc"
33
};
34

35
/* @note See https://docs.zephyrproject.org/4.0.0/doxygen/html/group__tls__credentials.html#ga640ff6dd3eb4d5017feaab6fab2bb2f7 */
36
mender_err_t
37
mender_add_dormant_certs(void) {
29✔
38
    int ret;
39

40
    // Add main certificate
41
    ret = tls_credential_add(
29✔
42
        CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_DORMANT_A, TLS_CREDENTIAL_CA_CERTIFICATE, dormant_certificate_a, sizeof(dormant_certificate_a));
43

44
    if (0 != ret) {
29✔
NEW
45
        mender_log_error("Failed to add dormant certificate A. (result = %d, error: %s)", ret, strerror(errno));
×
UNCOV
46
        return MENDER_FAIL;
×
47
    }
48

49
    // Add backup certificate
50
    ret = tls_credential_add(
29✔
51
        CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_DORMANT_B, TLS_CREDENTIAL_CA_CERTIFICATE, dormant_certificate_b, sizeof(dormant_certificate_b));
52

53
    if (0 != ret) {
29✔
NEW
54
        mender_log_error("Failed to add dormant certificate B. (result = %d, error: %s)", ret, strerror(errno));
×
NEW
55
        return MENDER_FAIL;
×
56
    }
57

58
    return MENDER_OK;
29✔
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc