lightninglabs / lightning-coindesk

A tutorial news app exemplifying Lightning Network micropayments integration
54 stars 30 forks source link

_Rendezvous at /verify/ #2

Open zoedberg opened 7 years ago

zoedberg commented 7 years ago

After inserting the signature of the message it fails, telling the status code of the RPC is UNAVAILABLE. Here the traceback:

Environment:

Request Method: POST
Request URL: http://localhost:8000/verify/

Django Version: 1.11.1
Python Version: 2.7.13
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'whitenoise.runserver_nostatic',
 'django.contrib.staticfiles',
 'coindesk']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "/home/zoe/work/ln-workspace/deskenv/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/home/zoe/work/ln-workspace/deskenv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/zoe/work/ln-workspace/deskenv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/zoe/work/ln-workspace/lightning-coindesk/coindesk/views.py" in verify
  45.     user = authenticate(request=request, **kwargs)

File "/home/zoe/work/ln-workspace/deskenv/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in authenticate
  102.             user = backend.authenticate(*args, **credentials)

File "/home/zoe/work/ln-workspace/lightning-coindesk/coindesk/auth_backends.py" in authenticate
  26.         verifymessage_resp = stub.VerifyMessage(ln.VerifyMessageRequest(msg=csrf_token, signature=signature))

File "/home/zoe/work/ln-workspace/deskenv/local/lib/python2.7/site-packages/grpc/_channel.py" in __call__
  508.         return _end_unary_response_blocking(state, call, False, deadline)

File "/home/zoe/work/ln-workspace/deskenv/local/lib/python2.7/site-packages/grpc/_channel.py" in _end_unary_response_blocking
  455.         raise _Rendezvous(state, None, None, deadline)

Exception Type: _Rendezvous at /verify/
Exception Value: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Endpoint read failed)>
bulenttastan commented 6 years ago

The issue is happening because the server is trying to open an insecure_connection to the RPC server. I sent a pull request to fix the issue by opening a secure connection using the TLS certification file.

Quenos commented 6 years ago

Even with the PR I still have this issue

bulenttastan commented 6 years ago

@Quenos hmm, it worked for me, that's why I made the change. Do you know what's causing your issue?

Quenos commented 6 years ago

@bulenttastan Not yet. I'm also having the issue when following the next step in the tutorial, interacting using the command line.

Another thing I noticed that in said next step it says channel = grpc.secure_channel('localhost:10009', creds), but in your code you're interacting with port LND_RPCHOST (10002), but both are not working for me, so that is not the issue.

wintercooled commented 6 years ago

As a work around.... this worked for me (suggested by Tomas on LN slack) but not a long term fix (hard coded path etc)

before running edit: models.py and auth_backends.py (from source not the PR) and replace:

channel = grpc.insecure_channel(settings.LND_RPCHOST)

with: (make sure you line the indents up right with existing code - and it occurs 3 times in all)

   os.environ["GRPC_SSL_CIPHER_SUITES"] = "HIGH+ECDSA"
   cert = open('/home/yourhomenamehere/.lnd/tls.cert').read()
   creds = grpc.ssl_channel_credentials(cert)
   channel = grpc.secure_channel('localhost:10002', creds)

(assuming you have the tls.cert in that path that is - amend to point to it)

You just need to stop the server, edit the files and run python manage.py runserver again

ALSO - add the following to the top of those two files:

import os

Maybe it's the os.environ["GRPC_SSL_CIPHER_SUITES"] = "HIGH+ECDSA" that works for us as the other lines look functionally similar???

Quenos commented 6 years ago

@bulenttastan was just typing that :) Thanks for the good work!

adlererik commented 6 years ago

@wintercooled Thanks this worked for me. On Debian 9 GNU/Linux

doctorzhivago commented 6 years ago

One could also do something like: cert = open( '%s/.lnd/tls.cert' % (os.environ["LND_CERT_HOME"],)).read() in order to make it not use a hard coded path

samjhill commented 6 years ago

+1 I also get this error. After following @wintercooled 's instructions, I got a different, but seemingly related error:

Traceback (most recent call last):
  File "/Users/me/Documents/opensource/ln-workspace/deskenv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/me/Documents/opensource/ln-workspace/deskenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/me/Documents/opensource/ln-workspace/deskenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/me/Documents/opensource/ln-workspace/lightning-coindesk/coindesk/views.py", line 45, in verify
    user = authenticate(request=request, **kwargs)
  File "/Users/me/Documents/opensource/ln-workspace/deskenv/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 100, in authenticate
    user = backend.authenticate(*args, **credentials)
  File "/Users/me/Documents/opensource/ln-workspace/lightning-coindesk/coindesk/auth_backends.py", line 18, in authenticate
    verifymessage_resp = stub.VerifyMessage(ln.VerifyMessageRequest(msg=csrf_token, signature=signature))
  File "/Users/me/Documents/opensource/ln-workspace/deskenv/lib/python2.7/site-packages/grpc/_channel.py", line 507, in __call__
    return _end_unary_response_blocking(state, call, False, deadline)
  File "/Users/me/Documents/opensource/ln-workspace/deskenv/lib/python2.7/site-packages/grpc/_channel.py", line 455, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
_Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, failed to decode signature: illegal z-base-32 data at input byte 2)>

Anyone have any ideas?

edit: FIXED. On OSX. Originally, I tried pointing at /Users/me/Library/Application\ Support/Lnd/tls.cert, but that didn't work (due to permissions, I figured), so I tried pointing at a different copy of tls.cert in another folder, which also didn't work.

Then, I tried /Users/me/Library/Application Support/Lnd/tls.cert (no backslash) and it worked.

jinsu35 commented 6 years ago

In this tutorial (http://dev.lightning.community/tutorial/03-rpc-client/index.html), the server is connected to 'Bob' node but the instruction uses 'lncli-alice' to generate log-in credentials. Shouldn't it be 'lncli-bob'?