n7tae / mvoice

A prototype M17 voice application for ham radio
GNU General Public License v2.0
55 stars 13 forks source link

Error when setting subject key id The request is invalid #21

Closed Cale closed 2 months ago

Cale commented 2 months ago

mvoice compiled successfully on Ubuntu 22.04 after building OpenDHT from source.

When running mvoice I receive an error:

❯ bin/mvoice https://dvref.com/mrefd/json/?format=json copied to .config/mvoice/m17refl.json .config/mvoice/mvoice.cfg was not found! terminate called after throwing an instance of 'dht::crypto::CryptoException' what(): Error when setting subject key id The request is invalid. Aborted (core dumped)

I touched a blank config file which allowed the 'not found' message to go away.

The error seems to be centered around OpenDHT, but that's as far as I'm able to go with it.

Thanks for any pointers.

n7tae commented 2 months ago

Sorry, try as I might, I can't reproduce this. I believe you are crashing on line #315 of MainWindow.cpp, where your dht identity is created and used to start your dht node. Your callsign isn't configured yet, but the call to dht::crypto::generateIdentity() should still work even if you callsign string is empty.

Do you know how to use gdb? You'll have to set DEBUG to true in your mvoice.mk file, clean and re-make mvoice and then launch it with "gdb mvoice" and then "run". When it crashes, you'll get a prompt from gdb. Then do a "bt" and send me the output, and we'll go from there.

Cale commented 2 months ago

Thanks Tom. Here's the debug output:

(gdb) run
Starting program: /home/cale/bin/mvoice 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff51ff640 (LWP 39269)]
[Thread 0x7ffff51ff640 (LWP 39269) exited]
https://dvref.com/mrefd/json/?format=json copied to .config/mvoice/m17refl.json
[New Thread 0x7ffff51ff640 (LWP 39270)]
terminate called after throwing an instance of 'dht::crypto::CryptoException'
  what():  Error when setting subject key id The request is invalid.

Thread 1 "mvoice" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737320643200) at ./nptl/pthread_kill.c:44
44  ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737320643200) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737320643200) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737320643200, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff6e42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff6e287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff72a2b9e in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff72ae20c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff72ae277 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007ffff72ae4d8 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x00007ffff784d783 in dht::crypto::Certificate::generate(dht::crypto::PrivateKey const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::pair<std::shared_ptr<dht::crypto::PrivateKey>, std::shared_ptr<dht::crypto::Certificate> > const&, bool, long) ()
   from /lib/x86_64-linux-gnu/libopendht.so.3
#10 0x00007ffff784c5e1 in dht::crypto::generateIdentity(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::pair<std::shared_ptr<dht::crypto::PrivateKey>, std::shared_ptr<dht::crypto::Certificate> > const&, unsigned int, bool) () from /lib/x86_64-linux-gnu/libopendht.so.3
#11 0x00007ffff784c758 in dht::crypto::generateIdentity(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::pair<std::shared_ptr<dht::crypto::PrivateKey>, std::shared_ptr<dht::crypto::Certificate> > const&, unsigned int) () from /lib/x86_64-linux-gnu/libopendht.so.3
#12 0x00005555555ccb84 in CMainWindow::Init (this=0x7fffffffc880) at MainWindow.cpp:315
#13 0x00005555555d1b04 in main (argc=1, argv=0x7fffffffe018) at MainWindow.cpp:1113
n7tae commented 2 months ago

Well, that wasn't very helpful. Let's make sure you're not using the old package try:

apt list libopendht-dev

Cale commented 2 months ago

Sorry, was out of town and away from the laptop for a couple days. Here's the version:

libopendht-dev/jammy 2.3.1-1build3 amd64

n7tae commented 2 months ago

Sorry to put you through these hoops...

In an empty directory, can you please create dhttest.cpp containing:

#include <iostream>
#include <opendht.h>
#include <thread>
#include <string>

int main()
{
    dht::DhtRunner node;
    std::string s;
    //s.assign("mynode");
    node.run(17171, dht::crypto::generateIdentity(s), true, 59973);
    std::cout << "node is running\n";
    std::string bs("xrf587.openquad.net");
    node.bootstrap(bs);
    std::cout << "Bootstrap from " << bs << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(5));
    node.join();
    std::cout << "node is not running\n";
    return 0;
}

Then compile it: g++ -std=c++17 -o dhttest dhttest.cpp -lopendht -pthread

And run it: ./dhttest

If it crashes, uncomment the s.assign line (remove the //) and compile it and run it again.

Let me know what happens.

Cale commented 2 months ago

No worries at all. I just hope this helps others and isn't an edge-case because of something dumb on my machine.

It did crash initially, but uncommenting the requested line allowed it to run:

❯ ./dhttest 
terminate called after throwing an instance of 'dht::crypto::CryptoException'
  what():  Error when setting subject key id The request is invalid.
Aborted (core dumped)
❯ ./dhttest 
node is running
Bootstrap from xrf587.openquad.net
node is not running
n7tae commented 2 months ago

Thank you! I have pushed up a fix to mvoice that should work for you, mvoice version 1.1.4. I am going to close this issue. If you're still having problems, you can reopen it, or open a new issue.

Cale commented 2 months ago

Thanks, Tom. I pulled the latest and was able to compile, run, and connect. I appreciate the assistance!