- 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_srv.c b/library/ssl_srv.c
index 157a909..57fe82d 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -485,7 +485,7 @@
     p += 2;
     crt = ssl->ca_chain;
 
-    while( crt != NULL && crt->next != NULL )
+    while( crt != NULL && crt->version != 0 )
     {
         if( p - buf > 4096 )
             break;