Accept a trailing space at end of PEM lines

With certs being copy-pasted from webmails and all, this will probably become
more and more common.

closes #226
This commit is contained in:
Manuel Pégourié-Gonnard 2015-07-31 11:09:59 +02:00
parent e96ce08a21
commit 052d10c9d5
4 changed files with 55 additions and 0 deletions

View file

@ -236,12 +236,14 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
return( MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT );
s1 += strlen( header );
if( *s1 == ' ' ) s1++;
if( *s1 == '\r' ) s1++;
if( *s1 == '\n' ) s1++;
else return( MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT );
end = s2;
end += strlen( footer );
if( *end == ' ' ) end++;
if( *end == '\r' ) end++;
if( *end == '\n' ) end++;
*use_len = end - data;