Browse Source

Fixed size for mbedtls_x509_crt_parse() and mbedtls_pk_parse_key()

Paul-Louis Ageneau 1 year ago
parent
commit
1c446b64fc
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/impl/certificate.cpp

+ 2 - 2
src/impl/certificate.cpp

@@ -228,11 +228,11 @@ Certificate Certificate::FromString(string crt_pem, string key_pem) {
 
 	mbedtls::check(mbedtls_x509_crt_parse(crt.get(),
 	                                      reinterpret_cast<const unsigned char *>(crt_pem.c_str()),
-	                                      crt_pem.length()),
+	                                      crt_pem.size() + 1),
 	               "Failed to parse certificate");
 	mbedtls::check(mbedtls_pk_parse_key(pk.get(),
 	                                    reinterpret_cast<const unsigned char *>(key_pem.c_str()),
-	                                    key_pem.size(), NULL, 0, NULL, 0),
+	                                    key_pem.size() + 1, NULL, 0, NULL, 0),
 	               "Failed to parse key");
 
 	return Certificate(std::move(crt), std::move(pk));