Skip to content
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

PHP Creating an API context error #210

Open
1 task
jeraldpunx opened this issue Jan 27, 2021 · 5 comments
Open
1 task

PHP Creating an API context error #210

jeraldpunx opened this issue Jan 27, 2021 · 5 comments

Comments

@jeraldpunx
Copy link

jeraldpunx commented Jan 27, 2021

Steps to reproduce:

<?php
	require __DIR__ . '/vendor/autoload.php';
    use bunq\Context\ApiContext;
	use bunq\Util\BunqEnumApiEnvironmentType;

	$environmentType = BunqEnumApiEnvironmentType::SANDBOX(); // Can also be BunqEnumApiEnvironmentType::PRODUCTION();
	$apiKey = 'asdasdasdasd'; // Replace with your API key
	$deviceDescription = "JeraldPC"; // Replace with your device description
	$permittedIps = ['0.0.0.0']; // List the real expected IPs of this device or leave empty to use the current IP

	$apiContext = ApiContext::create(
	    $environmentType,
	    $apiKey,
	    $deviceDescription,
	    $permittedIps
	);

	BunqContext::loadApiContext($apiContext);

What should happen:

Create API Context

What happens:

Fatal error: Uncaught bunq\Exception\BunqException: Generating a new private key failed. See "http://php.net/manual/en/function.openssl-pkey-new.php" for more info. in D:\laragon\www\bunq\vendor\bunq\sdk_php\src\Security\KeyPair.php:66 Stack trace: #0 D:\laragon\www\bunq\vendor\bunq\sdk_php\src\Context\ApiContext.php(187): bunq\Security\KeyPair::generate() #1 D:\laragon\www\bunq\vendor\bunq\sdk_php\src\Context\ApiContext.php(178): bunq\Context\ApiContext->initializeInstallationContext() #2 D:\laragon\www\bunq\vendor\bunq\sdk_php\src\Context\ApiContext.php(119): bunq\Context\ApiContext->initialize('JeraldPC', Array) #3 D:\laragon\www\bunq\index.php(16): bunq\Context\ApiContext::create(Object(bunq\Util\BunqEnumApiEnvironmentType), 'a6785e1ff4f3964...', 'JeraldPC', Array) #4 {main} thrown in D:\laragon\www\bunq\vendor\bunq\sdk_php\src\Security\KeyPair.php on line 66

Traceback

SDK version and environment

  • Tested on 1.14.1
  • [check ] Sandbox
  • Production
@jeraldpunx
Copy link
Author

help, what is my problem here? I already have openSSL enabled in PHP

@basst85
Copy link

basst85 commented Jan 27, 2021

help, what is my problem here? I already have openSSL enabled in PHP

Hi,

Can you maybe create (and test) a simple PHP-script with only the following contents?

<?php
$config = array(
    "digest_alg" => "sha512",
    "private_key_bits" => 2048,
    "private_key_type" => OPENSSL_KEYTYPE_RSA,
);
   
$opensslKeyPair = openssl_pkey_new($config);

Because it looks like it's failing on this part of the script

@basst85
Copy link

basst85 commented Jan 27, 2021

Check also this installation info of OpenSSL:
https://www.php.net/manual/en/openssl.installation.php

@jeraldpunx
Copy link
Author

I'm still having hardtime. The libcrypto exist already on my apache and php but still not works.
image

@basst85
Copy link

basst85 commented Jan 28, 2021

I'm still having hardtime. The libcrypto exist already on my apache and php but still not works.

Is OpenSSL active and enabled in the PHPinfo output?
https://php.tutorials24x7.com/blog/how-to-configure-php-openssl-module-on-windows

And is the Window Environment Variable "OPENSSL_CONF" also set to the location of openssl.conf ?
https://seegatesite.com/the-steps-how-to-install-openssl-on-xampp-windows/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants