Fix length check. The docs are confusing.

Also, set cert_bio to NULL after free.