summaryrefslogtreecommitdiffstats
path: root/src/mbedTLS++/X509Cert.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2017-09-19 18:28:51 +0200
committerLukas Pioch <lukas@zgow.de>2017-09-19 19:44:30 +0200
commite0d1f791a33c3bf3f164b8c5abbd87a87d376471 (patch)
treeb1dddc4dbbc072626287b81f74f2507b4944f78f /src/mbedTLS++/X509Cert.cpp
parentChanged BroadcastSoundEffect, SendSoundEffect, and CastThunderbolt parameters to vectors (#3959) (diff)
downloadcuberite-e0d1f791a33c3bf3f164b8c5abbd87a87d376471.tar
cuberite-e0d1f791a33c3bf3f164b8c5abbd87a87d376471.tar.gz
cuberite-e0d1f791a33c3bf3f164b8c5abbd87a87d376471.tar.bz2
cuberite-e0d1f791a33c3bf3f164b8c5abbd87a87d376471.tar.lz
cuberite-e0d1f791a33c3bf3f164b8c5abbd87a87d376471.tar.xz
cuberite-e0d1f791a33c3bf3f164b8c5abbd87a87d376471.tar.zst
cuberite-e0d1f791a33c3bf3f164b8c5abbd87a87d376471.zip
Diffstat (limited to 'src/mbedTLS++/X509Cert.cpp')
-rw-r--r--src/mbedTLS++/X509Cert.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mbedTLS++/X509Cert.cpp b/src/mbedTLS++/X509Cert.cpp
index 4dd998f00..7bcfec415 100644
--- a/src/mbedTLS++/X509Cert.cpp
+++ b/src/mbedTLS++/X509Cert.cpp
@@ -30,7 +30,10 @@ cX509Cert::~cX509Cert()
int cX509Cert::Parse(const void * a_CertContents, size_t a_Size)
{
- return mbedtls_x509_crt_parse(&m_Cert, reinterpret_cast<const unsigned char *>(a_CertContents), a_Size);
+ // mbedTLS requires that PEM-encoded data is passed including the terminating NUL byte,
+ // and DER-encoded data is decoded properly even with an extra trailing NUL byte, so we simply add one to everything:
+ AString certContents(reinterpret_cast<const char *>(a_CertContents), a_Size);
+ return mbedtls_x509_crt_parse(&m_Cert, reinterpret_cast<const unsigned char *>(certContents.data()), a_Size + 1);
}