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

Any way of testing from localhost? [Question] #32

Closed
Ben-CA opened this issue Oct 7, 2023 · 1 comment
Closed

Any way of testing from localhost? [Question] #32

Ben-CA opened this issue Oct 7, 2023 · 1 comment

Comments

@Ben-CA
Copy link

Ben-CA commented Oct 7, 2023

This setup works great for me when running on an AWS instance, using:

    $role = file_get_contents('http://169.254.169.254/latest/meta-data/iam/security-credentials/');
    $jsonCredentials = file_get_contents('http://169.254.169.254/latest/meta-data/iam/security-credentials/' . $role);
    $credentials = json_decode($jsonCredentials, true);
    $configuration = new Configuration(
    $credentials['AccessKeyId'],
    $credentials['SecretAccessKey'],
    'v4',
    AWS_REGION
    );
    $configuration->setToken($credentials['Token']);
    $connector = new Connector($configuration);

However, I'm wondering if there's any easy way of testing with it on localhost. (Since it's only one small component of the application, and when making changes, it's nice to test everything before it hits the server.)

Setting up an Access Key / Secret from AWS Console doesn't provide a token. So I tried for instance running this on a test page on a AWS instance:

$role = file_get_contents('http://169.254.169.254/latest/meta-data/iam/security-credentials/');
$jsonCredentials = file_get_contents('http://169.254.169.254/latest/meta-data/iam/security-credentials/' . $role);
$credentials = json_decode($jsonCredentials, true);

echo $credentials['AccessKeyId'];
echo '<br />';
echo $credentials['SecretAccessKey'];
echo '<br />';
echo $credentials['Token'];

Which then gave me the 3 strings. (And I realize they'll have a fairly short lifespan) Then I tried passing them like this:


    $configuration = new Configuration(
    'AccessKeyIdHere',
    'SecretAccessKeyHere',
    'v4',
    'AWS_Region_Here'
    );
    $configuration->setToken('Token_Provided_Here');
    $connector = new Connector($configuration);

But when I try to use it, I get the following error:

Fatal error: Uncaught Akeeba\Engine\Postproc\Connector\S3v4\Exception\CannotGetBucket: Akeeba\Engine\Postproc\Connector\S3v4\Connector::internalGetBucket(): [60] SSL certificate problem: unable to get local issuer certificate in C:\project\vendor\akeeba\s3\src\Connector.php:935 Stack trace: #0 C:\project\vendor\akeeba\s3\src\Connector.php(460): Akeeba\Engine\Postproc\Connector\S3v4\Connector->internalGetBucket('BUCKETNAME...', 'folder...', NULL, NULL, '/', false) #1 C:\project\handlers\media_upload.php(83): Akeeba\Engine\Postproc\Connector\S3v4\Connector->getBucket('BUCKETNAME...', 'folder...') #2 {main} thrown in C:\project\vendor\akeeba\s3\src\Connector.php on line 935

SSL certificate problem: unable to get local issuer certificate

I have a CURL pem certificate package setup with my localhost PHP / Apache setup, but I'm obviously missing something.

There's not quite the same options as the bloated AWS SDK, which appears to have some provision for this:

https://stackoverflow.com/questions/24620393/aws-ssl-security-error-curl-60-ssl-certificate-prob-unable-to-get-local

I get the same error using this method as outlined in the Readme:

$configuration = new Configuration(
	'YourAmazonAccessKey',
	'YourAmazonSecretKey'
);

$connector = new \Connector($configuration);

If I add:
$configuration->setSSL(false);

Then I get:

[500] InvalidRequest:The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256

Has anyone else used this package with localhost and have any suggestions?

@Ben-CA
Copy link
Author

Ben-CA commented Oct 7, 2023

Figured it out:

    $configuration = new Configuration(
      'Key',
      'Secret',
      'v4',
      AWS_REGION
    );
    $configuration->setSSL(false);
    
    $connector = new Connector($configuration);

@Ben-CA Ben-CA closed this as completed Oct 7, 2023
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

1 participant