Fix bugs in TLS 1.2 support.