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

mendersoftware / mender / 2281564137

23 Jan 2026 10:59AM UTC coverage: 81.48% (+1.7%) from 79.764%
2281564137

push

gitlab-ci

michalkopczan
fix: Schedule next deployment poll if current one failed early causing no handler to be called

Ticket: MEN-9144
Changelog: Fix a hang when polling for deployment failed early causing no handler of API response
to be called. Added handler call for this case, causing the deployment polling
to continue.

Signed-off-by: Michal Kopczan <michal.kopczan@northern.tech>

1 of 1 new or added line in 1 file covered. (100.0%)

327 existing lines in 44 files now uncovered.

8839 of 10848 relevant lines covered (81.48%)

20226.53 hits per line

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

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

15
#ifndef MENDER_COMMON_CRYPTO_HPP
16
#define MENDER_COMMON_CRYPTO_HPP
17

18
#include <cstdint>
19
#include <string>
20
#include <vector>
21

22
#include <common/expected.hpp>
23
#include <artifact/sha/sha.hpp>
24

25
namespace mender {
26
namespace common {
27
namespace crypto {
28

29
using namespace std;
30

31
namespace sha = mender::sha;
32

33
enum CryptoErrorCode {
34
        NoError = 0,
35
        SetupError,
36
        Base64Error,
37
        VerificationError,
38
};
39

40
struct Args {
41
        string private_key_path;
42
        string private_key_passphrase;
43
        string ssl_engine;
44
};
45

46
class PrivateKey;
47
using ExpectedPrivateKey = expected::expected<std::unique_ptr<PrivateKey>, error::Error>;
48

49
#ifdef MENDER_CRYPTO_OPENSSL
50
class OpenSSLResourceHandle;
51
using ResourceHandlePtr = unique_ptr<OpenSSLResourceHandle, void (*)(OpenSSLResourceHandle *)>;
52
using PkeyPtr = unique_ptr<EVP_PKEY, void (*)(EVP_PKEY *)>;
53
#endif // MENDER_CRYPTO_OPENSSL
54

55
class PrivateKey {
56
public:
57
        PrivateKey() {};
58
        PrivateKey(const PrivateKey &) = delete;
59
        PrivateKey &operator=(const PrivateKey &) = delete;
60

61
        static ExpectedPrivateKey Load(const Args &args);
62
        static ExpectedPrivateKey Generate();
63
        error::Error SaveToPEM(const string &private_key_path);
64

65
#ifdef MENDER_CRYPTO_OPENSSL
66
        PkeyPtr key {nullptr, [](EVP_PKEY *) { return; }};
67

68
        ResourceHandlePtr resource_handle_ {nullptr, [](OpenSSLResourceHandle *) { return; }};
69

70
        EVP_PKEY *Get() {
71
                return key.get();
72
        }
73

74
        operator bool() {
75
                return key != nullptr;
76
        }
77

78
        PrivateKey(PkeyPtr &&private_key) :
40✔
79
                key(std::move(private_key)) {};
40✔
80

UNCOV
81
        PrivateKey(PkeyPtr &&private_key, ResourceHandlePtr &&resource_handle) :
×
82
                key {std::move(private_key)},
UNCOV
83
                resource_handle_(std::move(resource_handle)) {};
×
84

85
#endif // MENDER_CRYPTO_OPENSSL
86
};
87

88
class CryptoErrorCategoryClass : public std::error_category {
89
public:
90
        const char *name() const noexcept override;
91
        string message(int code) const override;
92
};
93
extern const CryptoErrorCategoryClass CryptoErrorCategory;
94

95
error::Error MakeError(CryptoErrorCode code, const string &msg);
96

97
expected::ExpectedString ExtractPublicKey(const Args &args);
98

99
expected::ExpectedString EncodeBase64(vector<uint8_t> to_encode);
100

101
expected::ExpectedBytes DecodeBase64(string to_decode);
102

103
expected::ExpectedString Sign(const Args &args, const vector<uint8_t> &raw_data);
104

105
expected::ExpectedBool VerifySign(
106
        const string &public_key_path, const sha::SHA &shasum, const string &signature);
107

108
} // namespace crypto
109
} // namespace common
110
} // namespace mender
111

112

113

114
#endif // MENDER_COMMON_CRYPTO_HPP
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

© 2026 Coveralls, Inc