TransWikia.com

SSL handshake failed due to unexpected packet format

Monero Asked on February 19, 2021

I am trying to connect to a Monero stage net node to make some basic RPC calls and start building a library for working with Monero however I am getting an SSL error when connectiong.

using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Monero;
using Newtonsoft.Json;

namespace Monero
{
    public class Request
    {
        public readonly string jsonrpc = "2.0";
        public readonly string id = "0";
        public readonly string METHOD = "get_version";
    }
}

namespace Monero_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Monero.Request c1 = new Monero.Request();
            string json = JsonConvert.SerializeObject(c1);
            Console.WriteLine("Json = {0}", json);

            HttpClient client = new HttpClient();
            try
            {
                var content = new StringContent(json, Encoding.UTF8, "application/json");
                var response = client.PostAsync("https://monero-stagenet.exan.tech:38081/json_rpc", content);
                Console.WriteLine(response.Result.RequestMessage.Content.ReadAsStringAsync().Result); 
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
            }

            Console.ReadKey();
        }
    }
}

error:

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> System.IO.IOException: The handshake failed due to an unexpected packet format.
   at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---

How would I go about rectifying this?

One Answer

  1. Use a daemon that is up and running
  2. Use a daemon that is running with SSL configured
  3. If using a daemon that is auto-detecting SSL clients, configure your client to allow self-signed certificates.

Answered by jtgrassie on February 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP