~jpgleeson/spawsh

f534f738ec0e6014ec77541ab3547575c8fcbf5f — Jack Gleeson 5 months ago 6cb468e
TOFU Work

Working on fixing TOFU error. This has stopped working on some sites the second time they are fetched in a session. I believe I just need to persist the certs sent and send them with the SslStream.
1 files changed, 12 insertions(+), 1 deletions(-)

M Program.cs
M Program.cs => Program.cs +12 -1
@@ 16,10 16,11 @@ namespace spawsh
        static bool inInteractive = false;
        static int selectedLinkIndex = -1;
        static string currentPage;
        static X509CertificateCollection collection;

        static void Main(string[] args)
        {

            collection = new X509CertificateCollection();
            string server = "gemini.circumlunar.space";
            string page = "/";
            bool validProtocol = true;


@@ 91,6 92,7 @@ namespace spawsh
        public static bool ValidateServerCertificate(object sender, X509Certificate certificate,
        X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            collection.Add(certificate);
            return true;
        }



@@ 219,6 221,15 @@ namespace spawsh
                using (SslStream sslStream = new SslStream(client.GetStream(), false,
                new RemoteCertificateValidationCallback(ValidateServerCertificate), null))
                {
                    Console.WriteLine(collection.Count);
                    foreach (X509Certificate cert in collection)
                    {
                        if (cert.GetType() == typeof(X509Certificate))
                        {
                            
                        }
                    }

                    sslStream.AuthenticateAsClient(server);

                    byte[] messageToSend = Encoding.UTF8.GetBytes("gemini://" + server + page + '\r' + '\n');