Everyone, I have been toying with doing something with tor for a long time. I decided to start doing something with it. I wrote this quick POC in C# to connect to a tor node I got from the cache file. I tried to follow the specs in https://gitweb.torproject.org/torspec.git?a=blob_plain;hb=HEAD;f=tor-spec.txt section 2 connections, but apparently I’m doing something wrong. I’m hoping someone can help me out. Steven |
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Security.Authentication; namespace TorTests { class Program { private const string host = "81.223.215.102"; private const int port = 443; static void Main(string[] args) { using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { socket.Connect(host, port); using (var networkStream = new NetworkStream(socket)) using (var ssl = new SslStream(networkStream, false, CertificateValidation)) { var certificates = GetCollection(); ssl.AuthenticateAsClient(host, certificates, SslProtocols.Ssl3, false); } } } private static X509CertificateCollection GetCollection() { var collection = new X509CertificateCollection(); var certificate = new X509Certificate("TestServer.cer"); collection.Add(certificate); return collection; } private static bool CertificateValidation(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; } } }
Attachment:
TestServer.cer
Description: application/x509-ca-cert
Attachment:
makecerts.rename2bat
Description: Binary data
_______________________________________________ tor-dev mailing list tor-dev@xxxxxxxxxxxxxxxxxxxx https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev