Search code examples
pythondjangoamazon-web-servicesamazon-elastic-beanstalkbitcoin

Connecting to LND Node through a server-running Django Rest API


    @swagger_auto_schema(tags=['Payment'])
    def get(self, request):
    

        url = (
            "<instance address>"
        )
        macaroon = connect.encoded_hex

        TLS_PATH ='tls.cert'

        headers = {"Grpc-Metadata-macaroon": macaroon}
        r = requests.get(url, headers=headers, verify=TLS_PATH)  # disable SSL verification
        return Response(json.loads(r.text))

So I can connect and get the Info when sending a request from my local machine but it fails when sending request from my EC2 running on Elastic Beanstalk env with load balancer. I'm running a t3a.large instance type and Using Django as a framework.

Can anyone help as by now I've tried many different solutions.

This is the error I get :

HTTPSConnectionPool(host='<host>', port=8080): Max retries exceeded with url: /v1/getinfo (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1131)'))) 

THANK YOU


Solution

  • I had the same problem, solved it by adding my server endpoint and public ipv4 (where lnd is running) to the lnd.conf file like this:

    tlsextraip=127.0.0.1, <public_ipv4>
    tlsextradomain=ec2-x-aa-bb-cc.eu-central-1.compute.amazonaws.com
    

    and then stop lnd, delete the tls.cert and start lnd again to generate a new tls.cert. as it is self-signed certificate you should add it to the trusted certificates too.