• Hi,

    I have WP OAuth Server CE plugin running successfully on one of my wordpress sites.

    I am now trying to activate WP OAuth Server CE plugin on another wordpress site (v5.7.8) but I get a fatal error.

    Anyone know why I would get this error and how this can be fixed?

    Fatal error: Uncaught TypeError: openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, null given in plugins/oauth2-provider/includes/functions.php:388 Stack trace: #0 plugins/oauth2-provider/includes/functions.php(388): openssl_pkey_get_details(NULL) #1 plugins/oauth2-provider/wp-oauth-main.php(344): wp_oauth_generate_server_keys() #2 plugins/oauth2-provider/wp-oauth-main.php(229): WO_Server->install() #3 wp-includes/class-wp-hook.php(292): WO_Server->setup('') #4 wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) #5 wp-includes/plugin.php(484): WP_Hook->do_action(Array) #6 wp-admin/plugins.php(193): do_action('activate_oauth2...') #7 {main} thrown in plugins/oauth2-provider/includes/functions.php on line 388

    Any assistance would be very much appreciated.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Justin Greer

    (@justingreerbbi)

    Hi,

    Sorry for the issues. Looking at the error log that you reported, please ensure that the OpenSSL extension is installed or updated on your server for PHP.

    You can do this by contacting your host. They should be able to help you out. Let me know if the OpenSSL package resolves your issues.

    Thanks

    Thread Starter oravela

    (@oravela)

    Thanks Justin, I’ve got SSL installed on my site (pyro.org.uk) and I have Really Simple SSL plugin installed. Is there something else I should be doing as it seems to be set up the same way as my other site that is working.

    Thread Starter oravela

    (@oravela)

    I have double checked and I do have OpenSSL installed, the version installed is OpenSSL 1.0.1e-fips.
    Please could you confirm if your plugin is compatible with this version?

    • This reply was modified 2 years, 3 months ago by oravela.
    Thread Starter oravela

    (@oravela)

    Hi @justingreerbbi

    I have been doing some digging and spotted that the openssl_pkey_get_details is updated in php8.0

    https://www.php.net/manual/en/function.openssl-pkey-get-details.php

    I then downgraded my php to 7.4, and that allowed me to install your plugin. I could then upgrade to 8.0 with your plugin active.

    So I am guessing there is some incompatibility with your plugin installation code and php 8.0.

    Hope this helps you to improve the plugin.

    Plugin Author Justin Greer

    (@justingreerbbi)

    Interesting. Thank you for the update. I can look into why this would happen. The function is only used on install and regeneration of the certificates.

    Can you regenerate the certificates in the plugin settings status page now as well?

    Thread Starter oravela

    (@oravela)

    Hi @justingreerbbi

    No, I get a critical error …

    Warning: openssl_pkey_export(): Cannot get key from parameter 1 in public_html/wp-content/plugins/oauth2-provider/includes/functions.php on line 383
    
    Fatal error: Uncaught TypeError: openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given in 
    public_html/wp-content/plugins/oauth2-provider/includes/functions.php:388 Stack trace:
    #0 public_html/wp-content/plugins/oauth2- provider/includes/functions.php(388): openssl_pkey_get_details(false)
    #1 public_html/wp-content/plugins/oauth2-provider/includes/actions.php(109): wp_oauth_generate_server_keys(true)
    #2 public_html/wp-includes/class-wp-hook.php(292): wp_oauth_regenerate_certificates('')
    #3 /public_html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters('', Array)
    #4 public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array)
    #5 public_html/wp-admin/admin-post.php(70): do_action('admin_post_wpoa...')
    #6 {main} thrown in public_html/wp-content/plugins/oauth2-provider/includes/functions.php on line 388
    • This reply was modified 2 years, 3 months ago by oravela.
    • This reply was modified 2 years, 3 months ago by oravela.
    • This reply was modified 2 years, 3 months ago by oravela.
    Plugin Author Justin Greer

    (@justingreerbbi)

    Ok. It looks like PHP 8 has an issue on your server for some reason. I am unable to replicate this issue on any of our instances running PHP 8, 8.0.1, or 8.1.0.

    We will investigate it a bit more and see if we can tweak our environment to cause the issue so we can debug.

    Thanks for replying!

    Thread Starter oravela

    (@oravela)

    @justingreerbbi

    Even in PHP 7.4 I still get an error when trying to regenerate the certificates and the public and private keys show as 0 Bytes which can’t be right. The warning messages are:

    Warning: openssl_pkey_export(): cannot get key from parameter 1 in public_html/wp-content/plugins/oauth2-provider/includes/functions.php on line 383
    
    Warning: openssl_pkey_get_details() expects parameter 1 to be resource, bool given in public_html/wp-content/plugins/oauth2-provider/includes/functions.php on line 388
    
    Warning: Cannot modify header information - headers already sent by (output started at public_html/wp-content/plugins/oauth2-provider/includes/functions.php:383) in public_html/wp-includes/pluggable.php on line 1331
    
    Warning: Cannot modify header information - headers already sent by (output started at public_html/wp-content/plugins/oauth2-provider/includes/functions.php:383) in public_html/wp-includes/pluggable.php on line 1334
    Plugin Author Justin Greer

    (@justingreerbbi)

    This issue is almost certainly a configuration issue with OpenSSL and PHP. Doing some digging online, it looks like this is an issue around hosting using Windows. Looking at your site information for the server and services, it suggests you are on a Windows OS for hosting.

    I have added a to-do list to check server environments on install and to try and use alternative less streamlined methods for generating certifcates.

    For the time being, it looks like Windows does not define the OpenSSL.cnf file in the environment to be accessed and must be manually added if it doesn’t.

    We are looking at ways to manage this. At the moment, I can not provide an actuarate timeline but we will get to it.

    Thread Starter oravela

    (@oravela)

    Hi @justingreerbbi

    Thanks for looking into this.

    My hosting environment is:
    Linux cweb2-c17937.website-staging.uk 4.18.0 #1 SMP Thu Sep 23 18:26:47 MSK 2021 x86_64

    So not windows OS.

    Is there something I can check to see if the OpenSSL.cnf file is accessible? Where would I find it?

    Thanks again.

    Thread Starter oravela

    (@oravela)

    Hi @justingreerbbi

    I have had confirmation that my OpenSSL.cnf file exists and is located at /etc/pki/tls/openssl.cnf

    Is that location ok for your plugin?

    I also use the UpdraftPlus plugin which is working fine. Do you know if there are any compatibility issues between this one and your plugin?

    Still trying to get your plugin working so any input would be amazing.

    Many thanks.

    Thread Starter oravela

    (@oravela)

    Hi @justingreerbbi

    So I discovered that on my hosting site openssl_pkey_new(); is returning FALSE and this is then having a knock on impact resulting in the errors when trying to generate private and public keys. I thought you might like to know in case you want to tidy up the error handling in functions.php

    Also my hosting site developers have now come back to me to say that the hosting environment does not support OpenSSL.

    Do you happen to know any other options open to me if I can’t use OpenSSL? I’m not looking forward to having to do a full migration to another hosting environment.

    As always, really appreciate your help/input on this.

    Plugin Author Justin Greer

    (@justingreerbbi)

    Hi,

    As of right now, there is no other way to handle this. We have been exploring other options like 3rd party plugins. The issue with them is they introduce a layer that we can not control but we are still moving forward with the idea.

    We may have an option here in the near future to enable the 3rd party stuff but again, we are cautious.

    Thread Starter oravela

    (@oravela)

    Hi @justingreerbbi

    Thank you for getting back to me. I am almost there but have one hopefully final error to overcome.

    I have made some progress and can now install, uninstall and re-install your plugin on my two web hosting packages. Regenerating the certificates also works.

    I am using your plugin to allow my wordpress users to automatically log in to a wiki. On my old web server, the log in works fine from wordpress to the wiki and when I change the client to point to the wiki on the new web server that also works. Which means I believe the wiki is setup ok on both web servers as old web server wordpress can log in to both old and new web server wikis using your plugin.

    However no matter what I do I cannot get my wordpress on the new web server to log in to either the old wiki on the old web server or the new wiki on the new web server.

    The error reported at the wiki end is as below. I have checked the user details on both wordpress sites and all details are the same except for user_id. user_login and user_email are identical on both wordpress sites. Can a different user_id cause an error?

    Any ideas on what I can check to overcome this error? What can I check in the wordpress logs to identify the cause/difference between the two sites?

    Many thanks, Mark

    [Y5n3FyFO45RrVRrG06djUQAA6RA] /yellowbook_test/index.php/Special:OAuth2Client/callback?code=adra82riptvidwjvwtzr38nf6g9umftl1ried1u4&iframe=break League\OAuth2\Client\Provider\Exception\IdentityProviderException: invalid_request

    Thread Starter oravela

    (@oravela)

    @justingreerbbi

    In case this helps anyone else.

    Everything seems to be working after I changed my siteurl and home in wp_options to be my web site address without www

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Warning: Undefined var $res in oauth2-provider/includes/functions.php line 388’ is closed to new replies.