Skip to content

Commit 50fd78c

Browse files
committed
lib: cert: free mbedtls cert chain after parsing
If the chain is not freed, then subsequent attempts to parse the server cert will fail. Signed-off-by: Sam Friedman <sam@golioth.io>
1 parent 238722a commit 50fd78c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/cert.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ static int server_crt_update(size_t len)
125125
if (ret < 0)
126126
{
127127
LOG_ERR("Failed to parse certificate: 0x%x", -ret);
128+
mbedtls_x509_crt_free(&cert_chain);
129+
128130
return -EIO;
129131
}
130132

@@ -136,6 +138,8 @@ static int server_crt_update(size_t len)
136138
atomic_set(&server_crt_len, len);
137139
atomic_inc(&server_crt_id);
138140

141+
mbedtls_x509_crt_free(&cert_chain);
142+
139143
return 0;
140144
}
141145

0 commit comments

Comments
 (0)