Skip to content

Commit b489415

Browse files
author
Arto Kinnunen
authored
Add own certificate handling APIS (#2149)
Added certificate handling APIs
1 parent 586f2f2 commit b489415

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

nanostack/net_interface.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ typedef struct {
238238
/** Certificate structure. */
239239
typedef struct {
240240
const uint8_t *cert; /**< Certificate pointer. */
241+
const uint8_t *key; /**< Key pointer. */
241242
uint16_t cert_len; /**< Certificate length. */
243+
uint16_t key_len; /**< Key length. */
242244
} arm_certificate_entry_s;
243245

244246
/** Certificate Revocation List structure. */
@@ -921,6 +923,37 @@ extern int8_t arm_network_trusted_certificate_add(const arm_certificate_entry_s
921923
*/
922924
extern int8_t arm_network_trusted_certificate_remove(const arm_certificate_entry_s *cert);
923925

926+
/**
927+
* Remove trusted certificates
928+
*
929+
* This is used to remove all trusted root or intermediate certificates.
930+
*
931+
* \return 0 on success, negative on failure.
932+
*/
933+
extern int8_t arm_network_trusted_certificates_remove(void);
934+
935+
/**
936+
* Add own certificate
937+
*
938+
* This is used to add own certificate and private key.
939+
* In case intermediate certificates are used, function can be called several times. Each call
940+
* to the function adds a certificate to own certificate chain.
941+
* Certificates are in bottom up order i.e. the top certificate is given last.
942+
*
943+
* \param cert Certificate.
944+
* \return 0 on success, negative on failure.
945+
*/
946+
extern int8_t arm_network_own_certificate_add(const arm_certificate_entry_s *cert);
947+
948+
/**
949+
* Remove own certificates
950+
*
951+
* This is used to remove own certificates (chain).
952+
*
953+
* \return 0 on success, negative on failure.
954+
*/
955+
extern int8_t arm_network_own_certificates_remove(void);
956+
924957
/**
925958
* Add Certificate Revocation List
926959
*

source/libNET/src/ns_net.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,22 @@ int8_t arm_network_trusted_certificate_remove(const arm_certificate_entry_s *cer
964964
#endif
965965
}
966966

967+
int8_t arm_network_trusted_certificates_remove(void)
968+
{
969+
return -1;
970+
}
971+
972+
int8_t arm_network_own_certificate_add(const arm_certificate_entry_s *cert)
973+
{
974+
(void) cert;
975+
return -1;
976+
}
977+
978+
extern int8_t arm_network_own_certificates_remove(void)
979+
{
980+
return -1;
981+
}
982+
967983
int8_t arm_network_certificate_revocation_list_add(const arm_cert_revocation_list_entry_s *crl)
968984
{
969985
#ifdef HAVE_WS

0 commit comments

Comments
 (0)