- Fixed bug resulting in failure to send the last certificate in the chain in ssl_write_certificate() and ssl_write_certificate_request()

diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 17279ee..edd1b8e 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -1160,7 +1160,7 @@
     i = 7;
     crt = ssl->own_cert;
 
-    while( crt != NULL && crt->next != NULL )
+    while( crt != NULL && crt->version != 0 )
     {
         n = crt->raw.len;
         if( i + 3 + n > SSL_MAX_CONTENT_LEN )