-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openssl_pkey_export(): cannot get key from parameter #11227
Comments
A new key is generated in line 296. You could add When you switch to the user running nextcloud (i guess something like www-data or a dedicated user) can you open /etc/ssl/openssl.cnf than? |
Hi, thanks for the fast reply. Permissions are: "-rw-r--r-- 1 root root 10835 Feb 2 2016 /etc/ssl/openssl.cnf" added the line, here the output of the log again. New Log
|
Well. I guess you could copy openssl.cnf to /data/www/xxx.de/ and change path in config.php? The permission for openssl.cnf looks okay. daniel@daniel-pc:~$ ls -al /etc/ssl/ total 48 drwxr-xr-x 4 root root 4096 Jun 21 15:24 . drwxr-xr-x 139 root root 12288 Sep 14 11:42 .. drwxr-xr-x 3 root root 16384 Aug 2 15:38 certs -rw-r--r-- 1 root root 10771 Apr 25 19:03 openssl.cnf drwx--x--- 2 root ssl-cert 4096 Mai 22 19:29 private I can open openssl.cnf from another user. For openssl_pkey_new a valid openssl.cnf is required (that includes that the file is readable) |
I tried this, same errors again in the log. The openssl.cnf is now in the xxx.de/ folder and is owned by www-data. I also adjusted the path in config.php. It is readable by the www-data user. I checked some info with phpinfo() regarding my php openssl installation, here the default location seems to be "/usr/lib/ssl/openssl.cnf" which is also not readable by www-data. |
Ok. I guess the 'openssl' configuration from config.php is missing in this place. Could you try edit this place server/lib/private/Authentication/Token/PublicKeyTokenProvider.php Lines 290 to 293 in 47b46fa
and add another element |
or you try this (merge local settings with settings from config.php) |
Tried this. Log is now: New Log
|
Could you add |
Now Code is:
|
I can reproduce your error when i remove the permission to read openssl.cnf.
Could you place the code above in a file (e.g. openssl_test.php) on your server and execute it from web and cli? php openssl_test.php /home/vagrant/openssl_test.php:10: resource(4) of type (OpenSSL key) /home/vagrant/openssl_test.php:11: string(68) "error:0E06D06C:configuration file routines:NCONF_get_string:no value" As long as openssl.cnf is readable it works for me. |
The Permissions of /var/www/xxx.de/openssl.cnf are: and of /etc/ssl/openssl.cnf Error shown in GUI after adding you code: I tried to chmod 777 on openssl.cnf in /var/www/xxx.de/public_data/ without success. Same error shown. Edit: PHP is running under www-data. www-data also is owner of all Subdirectories within "/var/www/". Edit2:
CLI run via root user: CLI run via sudo -u www-data: Web: i also added the path to openssl.cnf to the testfile, still permission denied even if the openssl.cnf file is in the same directory as the testfile and has an chmod 777 on it. |
This is ok (no value is a warning) |
Oh i see, sorry. Running sudo -u www-data cat /var/www/xxx.de/public_data/openssl.cnf runs fine. |
Doing an sudo -u www-data strace php openssl_test.php gives the following lines:
The openssl_test.php contains:
So, maybe the problem is that php is first looking on the default location and then on the one specified? Edit:
So, i dont know if it is right to have only rw on root under this folder, comparing to yours you have rx on group and others. Edit2: Got it working now. Changed the /etc/ssl/ Permissions. chmod go+rx /etc/ssl/ does the trick. |
Problem solved so we can close the ticket 👍 |
`<?php $config = [ $res = openssl_pkey_new($config); var_dump($res); root@Openwrt:/opt/wwwroot# sudo -u nobody php-cli phpopenssl.php openssl version i have already added into config. error log listed: {"reqId":"E4mpumpeRrchnxzNv8rE","level":3,"time":"2018-09-30T05:25:31+00:00","remoteAddr":"2409:891e:6c40:3079:c38:519:95fd:48f0","user":"--","app":"index","method":"GET","url":"/","message":{"Exception":"TypeError","Message":"openssl_pkey_get_details() expects parameter 1 to be resource, boolean given","Code":0,"Trace":[{"file":"/opt/wwwroot/Nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php","line":300,"function":"openssl_pkey_get_details","args":[false]},{"file":"/opt/wwwroot/Nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php","line":270,"function":"newToken","class":"OC\Authentication\Token\PublicKeyTokenProvider","type":"->", |
Does work for you as well? |
no i have no problem with permission run script show error means php-mod-openssl? have some problem? |
new log |
This looks ok. resource(4) of type (OpenSSL key) is passed to PublicKeyTokenProvider::encrypt(). |
@danielkesselberg how about error it prompte and refer to my log above how to resolve the internal server error thanks |
Could you look for this line
and add |
add
no output since exit(); |
error log still |
Hmm. Could you add the line, open nextcloud, try to login and see if there is any output? |
I've been having a similar issue as @darkrain88. I'm using Debian Stretch. I followed the above steps and checked permissions. I added the three lines mentioned above and my browser gets this error message:
In my log file for a desktop user :
for a mobile/app user:
I also ran @darkrain88's script and got the following output:
From my
I commented out a line:
This changed the output of @darkrain88's test script:
I'm still getting the The change in |
but i cant login in some internal error/
add line, how to do that? |
can replace sha512 to v3_ca `<?php $config = [ $res = openssl_pkey_new($config); var_dump($res); |
Could you look for this file on your nextcloud instance and insert this code below Then open nextcloud with your browser and try to login. I guess you should see a white page with some output. Because |
@danielkesselberg that is.nothing output only 500 error |
Sorry @darkrain88 i have no idea what is going wrong in your case 😞 |
information 'string(39) "error:02001002:lib(2):func(1):reason(2)"' the output is same with run script above. |
@darkrain88 could you open a new issue for this? The original issue @Marcwa19197 started this ticket has been solved. There is only a little change that someone else is looking in a closes issue. Thank you 👍 and dont forget to provide as much as possible information. |
thanks you |
use openssl_pkey_export($res, $privateKey, NULL, $config) |
This solution works for me!! Change the code of PublicKeyTokenProvider.php
|
@kesselb, found a solution here... |
@0xb0ba I tried this but I get the same errors. |
i meet the same problem install version 16.0, and i added the value blew $res = openssl_pkey_new($config);:
and get the error:
next, i added the value in config/config.php: array ( the private_key_bits i added 2048,but the same errors, |
@0xb0ba Passing
We should check the response and log errors again just in case. Sorry for the late reply 🙈 |
Fix is in #16495 |
For Window System
|
Steps to reproduce
Expected behaviour
Login should be possible without errors in log or on webgui.
Actual behaviour
Getting an
"Internal Server Error
The server was unable to complete your request.
If this happens again, please send the technical details below to the server administrator.
More details can be found in the server log."
On the WebGui, also the Desktop Clients dont work anymore.
Server configuration
Operating system:
Ubuntu 16.04.5
Web server:
Apache/2.4.18 (Ubuntu)
Database:
mysqld Ver 5.7.23-0ubuntu0.16.04.1 for Linux on x86_64 ((Ubuntu))
PHP version:
PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS )
Nextcloud version: (see Nextcloud admin page)
14.0.0.19
Updated from an older Nextcloud/ownCloud or fresh install:
yes, updated from 13.0.6.1
Where did you install Nextcloud from:
Zip Package, downloaded from the offical site.
Signing status:
Signing status
List of activated apps:
App list
Nextcloud configuration:
Config report
Are you using external storage, if yes which one: no
Are you using encryption: no
Are you using an external user-backend, if yes which one: no, normal database-users
Client configuration
Browser:
dont matter
Operating system:
dont matter
Logs
Web server error log
Web server error log
Nextcloud log (data/nextcloud.log)
Nextcloud log
Browser log
Browser log
Same issue is reported here: https://help.nextcloud.com/t/nextcloud-runs-into-internal-errors-after-upgrade-from-v13-to-v14/36569
i cant find similar issue here as bug, so i added it.
The text was updated successfully, but these errors were encountered: