当前位置: 首页>>代码示例>>C#>>正文


C# SslStream.GetHashCode方法代码示例

本文整理汇总了C#中System.Net.Security.SslStream.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# SslStream.GetHashCode方法的具体用法?C# SslStream.GetHashCode怎么用?C# SslStream.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Security.SslStream的用法示例。


在下文中一共展示了SslStream.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main


//.........这里部分代码省略.........
                                checkCertificateRevocation: false
                            );

                            var RemoteCertificate = sslStream.RemoteCertificate;
                            Console.WriteLine(new { RemoteCertificate });
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(new { ex.Message });

                            if (ex.InnerException != null)
                                Console.WriteLine(new { ex.InnerException.Message });

                            return;
                        }


                        // ... Send and read data over the stream

                        // NET::ERR_CERT_AUTHORITY_INVALID



                        // issue NIC private key pfx?

                        // Error code: ERR_CONNECTION_REFUSED

                        // Your connection is not private
                        // NET::ERR_CERT_AUTHORITY_INVALID


                        //var x = sslStream.ReadByte();

                        Console.WriteLine("read " + sslStream.GetHashCode());

                        //read 1707556
                        //read 15368010
                        //read 4094363
                        //GET / HTTP/1.1
                        //Host: localhost:1300
                        //Connection: keep-alive
                        //Cache-Control: max-age=0
                        //Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
                        //User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2188.2 Safari/537.36
                        //Accept-Encoding: gzip, deflate, sdch
                        //Accept-Language: en-US,en;q=0.8

                        // Additional information: Stream was not readable.
                        #region 200
                        var rx = new StreamReader(sslStream);
                        Action y = delegate { };

                        while (true)
                        {
                            var rxl = rx.ReadLine();

                            if (string.IsNullOrEmpty(rxl))
                                break;

                            Console.WriteLine(rxl);

                            if (rxl == "GET / HTTP/1.1")
                                y = delegate
                                {
                                    // Error code: ERR_EMPTY_RESPONSE
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:66,代码来源:Program.cs

示例2: Main


//.........这里部分代码省略.........
                                    //}
                                    //);

                                };

                        }

                        y();
                    };
                    #endregion

                    if (zbuffer[0] == 0x47)
                    {
                        Console.WriteLine("enter http");
                        x200(p);
                        p.Close();
                        Console.WriteLine("exit http");
                        return;
                    }

                    if (zbuffer[0] == 0x16)
                    {
                        Console.WriteLine("enter https");
                        X509Certificate2 xcertificate = new X509Certificate2(@"X:\jsc.svn\examples\java\hybrid\JVMCLRSSLTCPListener\JVMCLRSSLTCPListener\bin\Debug\serverCert.cer.pfx", "xxx");


                        using (SslStream sslStream = new SslStream(
                            innerStream: p,
                            leaveInnerStreamOpen: false,

                            userCertificateSelectionCallback:
                                new LocalCertificateSelectionCallback(
                                    (object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers) =>
                        {
                            return localCertificates[0];
                        }
                                ),
                            userCertificateValidationCallback:
                                new RemoteCertificateValidationCallback(
                                    (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
                        {
                            Console.WriteLine(
                                new { certificate }
                                );

                            return true;
                        }
                                ),
                            encryptionPolicy: EncryptionPolicy.RequireEncryption

                            ))
                        {

                            try
                            {
                                // AuthenticateAsServer
                                // can this hang? if we use the wrong stream!

                                sslStream.AuthenticateAsServer(
                                    serverCertificate: CertificateFromCurrentUserByLocalEndPoint((IPEndPoint)clientSocket.Client.LocalEndPoint),
                                //clientCertificateRequired: false,
                                clientCertificateRequired: true,
                                // chrome for android does not like IIS TLS 1.2
                                enabledSslProtocols: System.Security.Authentication.SslProtocols.Tls12,
                                    checkCertificateRevocation: false
                                );

                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(new { ex.Message });

                                if (ex.InnerException != null)
                                    Console.WriteLine(new { ex.InnerException.Message });

                                return;
                            }

                            Console.WriteLine("read " + sslStream.GetHashCode());

                            x200(sslStream);
                            sslStream.Close();
                        }
                        Console.WriteLine("exit https");
                        return;
                    }


                    Console.WriteLine("exit other");
                    p.Close();

                };

            while (true)
                yield(
                    listener.AcceptTcpClient()
                );
            CLRProgram.CLRMain();

        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:Program.cs


注:本文中的System.Net.Security.SslStream.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。