Exemplo n.º 1
0
    /*
     * Try a SSLv2 connection. An error while opening the TCP
     * connection is reported as an exception. For all other errors,
     * null is returned.
     */
    SSL2 DoConnectV2()
    {
        Stream ns = null;

        try {
            ns = OpenConnection();
            if (readTimeout > 0)
            {
                RTStream rns = new RTStream(ns);
                rns.RTimeout = readTimeout;
                ns           = rns;
            }
            SSL2 v2 = SSL2.TestServer(ns);
            if (v2 != null)
            {
                rp.SSLv2CipherSuites = v2.CipherSuites;
                rp.SetSSLv2Certificate(v2.Certificate);
            }
            return(v2);
        } finally {
            try {
                if (ns != null)
                {
                    ns.Close();
                }
            } catch (Exception) {
                // ignored
            }
        }
    }
Exemplo n.º 2
0
 protected override void OnSerializeView(ref RTStream stream)
 {
     if (stream.isWriting)
     {
         stream.Write(transform.position);
         stream.Write(transform.rotation);
     }
     else if (stream.isReading)
     {
         transform.position = stream.Read <Vector3>();
         transform.rotation = stream.Read <Quaternion>();
     }
 }
 protected override void OnSerializeView(ref RTStream stream)
 {
     if(stream.isWriting)
     {
         stream.Write(transform.position);
         stream.Write(transform.localScale);
     }
     else
     {
         transform.position = stream.Read<Vector3>();
         transform.localScale = stream.Read<Vector3>();
     }
 }
Exemplo n.º 4
0
    /*
     * Try a connection with the current test settings. Connection
     * errors get through as exceptions. Other errors result in a
     * null returned value. If the handshake failed after the
     * ServerHello, then a non-null object is returned.
     */
    SSLTestResult DoConnect()
    {
        Stream ns = null;

        try {
            ns = OpenConnection();
            if (verbose)
            {
                Console.Write(".");
            }
            if (!gotSSLAnswer && readTimeout > 0)
            {
                RTStream rns = new RTStream(ns);
                rns.RTimeout = readTimeout;
                ns           = rns;
            }
            try {
                bool hasECExt = tb.SupportedCurves != null &&
                                tb.SupportedCurves.Length > 0;
                SSLRecord     rec = new SSLRecord(ns);
                SSLTestResult tr  = tb.RunTest(rec);
                gotSSLAnswer = true;
                if (tr != null)
                {
                    if (tr.DeflateCompress)
                    {
                        serverCompress = true;
                    }
                    AddServerChain(tr.CertificateChain);
                    AddServerTime(tr.TimeMillis);
                    AddServerDHSize(tr.DHSize);
                    AddServerECSize(tr.ECSize, hasECExt);
                    AddServerNamedCurve(tr.Curve);
                    if (tr.CurveExplicitPrime)
                    {
                        curveExplicitPrime = tr.ECSize;
                    }
                    else if (tr.CurveExplicitChar2)
                    {
                        curveExplicitChar2 = tr.ECSize;
                    }
                    if (tr.UnknownSKE)
                    {
                        unknownSKE = true;
                    }
                    if (tr.RenegotiationInfo != null)
                    {
                        doesRenego = true;
                    }
                    if (tr.DoesEtM)
                    {
                        doesEtM = true;
                    }
                }
                return(tr);
            } catch (SSLAlertException ae) {
                gotSSLAnswer = true;
                sslAlert     = ae.Alert;
                return(null);
            } catch (ReadTimeoutException) {
                gotReadTimeout = true;
                return(null);
            } catch (Exception) {
                return(null);
            }
        } finally {
            try {
                if (ns != null)
                {
                    ns.Close();
                }
            } catch (Exception) {
                // ignored
            }
        }
    }