monero-integrations / monerophp

Monero PHP library + JsonRPC Client
MIT License
116 stars 76 forks source link

Error: SSL certificate problem: self signed certificate #129

Closed ballonnetje closed 1 year ago

ballonnetje commented 2 years ago

Hi all,

Running Nginx server PHP7.4-fpm Ran monerod with command ./monerod --testnet --rpc-ssl-allow-any-cert --detach <<tried the allow any cert arg When visiting example.php on webserver I got this error: Fatal error: Uncaught RuntimeException: Unable to connect to https://127.0.0.1:28081/ Error: SSL certificate problem: self signed certificate in /var/www/public/src/jsonRPCClient.php:140 Stack trace: #0 /var/www/public/src/jsonRPCClient.php(80): MoneroIntegrations\MoneroPhp\jsonRPCClient->getResponse() #1 /var/www/public/src/daemonRPC.php(112): MoneroIntegrations\MoneroPhp\jsonRPCClient->_run() #2 /var/www/public/src/daemonRPC.php(129): MoneroIntegrations\MoneroPhp\daemonRPC->_run() #3 /var/www/public/example.php(16): MoneroIntegrations\MoneroPhp\daemonRPC->getblockcount() #4 {main} thrown in /var/www/public/src/jsonRPCClient.php on line 140

It's on a private ubuntu testing environment. Does the certificate problem occur because the webserver doesn't have a SSL certificate? (because its private)

serhack commented 2 years ago

It's a self-signed certificate and cURL complains about it. I'm sure there are better ways to manage those cases in jsonRPCClient.php.

Weldeasy commented 2 years ago

just pass a 3rd parameter to the classes like: $daemonRPC = new daemonRPC('127.0.0.1', 28081, false); and $walletRPC = new walletRPC('127.0.0.1', 28083, false);

ballonnetje commented 2 years ago

Thanks! That helped me getting to the next series of errors. Since I run the daemon and RPC through the TOR network, I had to use curl proxy statements. This is now fixed, but the only error im still getting is the get_connections() giving me this:

Request have return error: Method not found; Request: {"jsonrpc":"2.0","method":"get_connections","params":null}

spackle-xmr commented 2 years ago

I see this issue has been open for some time, but in case you or anyone else is still curious:

My suspicion is that you are sending the get_connections request to a port using the 'restricted' RPC API. I do not believe that the limited version of the API supports get_connections.

I confirmed this to myself by launching monerod (on mainnet) with the following options: ./monerod --rpc-restricted-bind-ip 0.0.0.0 --rpc-restricted-bind-port 18089 --no-igd --no-zmq --confirm-external-bind --public-node

Setting $daemonRPC = new daemonRPC('127.0.0.1', 18081); allows the example page to load since the full RPC API is available on 18081 by default. Setting $daemonRPC = new daemonRPC('127.0.0.1', 18089); will cause the 'Method not found' error.

I see serhack confirmed this in https://github.com/monero-integrations/monerophp/issues/118

recanman commented 1 year ago

@serhack can you close this?