- 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/debug.c b/library/debug.c
index c263e49..843b9f5 100644
--- a/library/debug.c
+++ b/library/debug.c
@@ -182,7 +182,7 @@
     prefix[maxlen] = '\0';
     maxlen = sizeof( str ) - 1;
 
-    while( crt != NULL && crt->next != NULL )
+    while( crt != NULL && crt->version != 0 )
     {
         char buf[1024];
         x509parse_cert_info( buf, sizeof( buf ) - 1, prefix, crt );