void CIRCSock::SockError(int iErrno, const CString& sDescription) {
    CString sError = sDescription;

    DEBUG(GetSockName() << " == SockError(" << iErrno << " " << sError << ")");
    if (!m_pNetwork->GetUser()->IsBeingDeleted()) {
        if (GetConState() != CST_OK) {
            m_pNetwork->PutStatus(
                t_f("Cannot connect to IRC ({1}). Retrying...")(sError));
        } else {
            m_pNetwork->PutStatus(
                t_f("Disconnected from IRC ({1}). Reconnecting...")(sError));
        }
#ifdef HAVE_LIBSSL
        if (iErrno == errnoBadSSLCert) {
            // Stringify bad cert
            X509* pCert = GetX509();
            if (pCert) {
                BIO* mem = BIO_new(BIO_s_mem());
                X509_print(mem, pCert);
                X509_free(pCert);
                char* pCertStr = nullptr;
                long iLen = BIO_get_mem_data(mem, &pCertStr);
                CString sCert(pCertStr, iLen);
                BIO_free(mem);

                VCString vsCert;
                sCert.Split("\n", vsCert);
                for (const CString& s : vsCert) {
                    // It shouldn't contain any bad characters, but let's be
                    // safe...
                    m_pNetwork->PutStatus("|" + s.Escape_n(CString::EDEBUG));
                }
                CString sSHA1;
                if (GetPeerFingerprint(sSHA1))
                    m_pNetwork->PutStatus(
                        "SHA1: " +
                        sSHA1.Escape_n(CString::EHEXCOLON, CString::EHEXCOLON));
                CString sSHA256 = GetSSLPeerFingerprint();
                m_pNetwork->PutStatus("SHA-256: " + sSHA256);
                m_pNetwork->PutStatus(
                    t_f("If you trust this certificate, do /znc "
                        "AddTrustedServerFingerprint {1}")(sSHA256));
            }
        }
#endif
    }
    m_pNetwork->ClearRawBuffer();
    m_pNetwork->ClearMotdBuffer();

    ResetChans();
    m_scUserModes.clear();
}
void CIRCSock::SockError(int iErrno, const CString& sDescription) {
    CString sError = sDescription;

    DEBUG(GetSockName() << " == SockError(" << iErrno << " " << sError << ")");
    if (!m_pNetwork->GetUser()->IsBeingDeleted()) {
        if (GetConState() != CST_OK) {
            m_pNetwork->PutStatus(
                t_f("Cannot connect to IRC ({1}). Retrying...")(sError));
        } else {
            m_pNetwork->PutStatus(
                t_f("Disconnected from IRC ({1}). Reconnecting...")(sError));
        }
#ifdef HAVE_LIBSSL
        if (iErrno == errnoBadSSLCert) {
             
            X509* pCert = GetX509();
            if (pCert) {
                BIO* mem = BIO_new(BIO_s_mem());
                X509_print(mem, pCert);
                X509_free(pCert);
                char* pCertStr = nullptr;
                long iLen = BIO_get_mem_data(mem, &pCertStr);
                CString sCert(pCertStr, iLen);
                BIO_free(mem);

                VCString vsCert;
                sCert.Split("\n", vsCert);
                for (const CString& s : vsCert) {
                     
                     
                    m_pNetwork->PutStatus("|" + s.Escape_n(CString::EDEBUG));
                }
                CString sSHA1;
                if (GetPeerFingerprint(sSHA1))
                    m_pNetwork->PutStatus(
                        "SHA1: " +
                        sSHA1.Escape_n(CString::EHEXCOLON, CString::EHEXCOLON));
                CString sSHA256 = GetSSLPeerFingerprint();
                m_pNetwork->PutStatus("SHA-256: " + sSHA256);
                m_pNetwork->PutStatus(
                    t_f("If you trust this certificate, do /znc "
                        "AddTrustedServerFingerprint {1}")(sSHA256));
            }
        }
#endif
    }
    m_pNetwork->ClearRawBuffer();
    m_pNetwork->ClearMotdBuffer();

    ResetChans();
    m_scUserModes.clear();
}