Symfony SSL connect error for in http client - php

I use http client component in my project symfony for external apis but I found this error when i test api:
SSL connect error for url
configuration of component is basic configuration and also create for request if simple with request method
$client = $this->client->request(
'GET',
$this->getUrl($route) . $query,
$this->options
);
I use a certificate for https and I enabled openssl extension, also I try to user verify_peer option in options parameters but also error.
How to fix this error?

Related

SSL error when trying to connect to Azure API

I am trying to connect to Azure API.I am kinda new to this.I am using the php code given in the samples.I am using wamp on my local server.
I have configured SSL on localhost so that I am able to open https://www.wamphelpers.dev/faces.php
However I keep getting the error below:
Failed to enable crypto stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in <b>C:\wamp\bin\php\php5.5.12\pear\HTTP\Request2\Adapter\Socket.php
My code is below:
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://southeastasia.api.cognitive.microsoft.com/face/v1.0/persongroups/{personGroupId}');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => 'keygoeshere',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'personGroupId' => 'heroes',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_PUT);
// Request body
$request->setBody("heroes");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
From what I have read it is a certificate issue and I have checked my php settings and made sure it is pointing to the right file.
out is below:
OPENSSL_CONF C:\OpenSSL-Win32\bin\openssl.cfg
I read a little and it seems I can disable SSL check in PHP using the context_options by making verify peer to false.
But how do I use it to hit the URL.
Below is the link for the API reference.
Just point HTTP/Request2 to use a CA bundle, as instructed here.
ssl_cafile
Certificate Authority file to verify the peer with (use when ssl_verify_peer is TRUE). You can use e.g. cURL's CA Extract tool to get such a file.
$request = new HTTP_Request2();
$request->setConfig(array(
'ssl_cafile' => '/path/to/cacert.pem'
));
The remote certificate can now be verified against the complete chain.

Asana PHP API Connection Error : 443

I am trying to use the Asana PHP API to build a browser project for personal use, but I am facing problems with connecting to the API.
This is the response i get when trying to fetch the user data from the API.
Fatal error: Uncaught exception 'Httpful\Exception\ConnectionErrorException' with message 'Unable to connect to "https://app.asana.com/api/1.0/users/me": 35 Unknown SSL protocol error in connection to app.asana.com:443 ' in php-asana\vendor\nategood\httpful\src\Httpful\Request.php:208
Here is the code I am using for initializing and fetching the data
require 'php-asana/vendor/autoload.php';
$client = Asana\Client::accessToken(PERSONAL_ACCESS_TOKEN);
$users = $client->users->me();
print_r($users);
The app is set up on my local server. Is it necessary for the client server to have SSL in order to fetch data from the Asana API or am I doing something wrong?
You might be using a deprecated version of TLS to do your requests, please see Asana is now deactivating TLS 1.0
Additionally, the library you are using may not support secure connections

endpoint not exist for Mailgun V3 issue with Yii2 extension

I am using https://github.com/boundstate/yii2-mailgun
Yii2 extension for Mailgun and extending it on my wrapper class.
i configure as shown in documentation in web.php ,
'mailer' => [
'class' => 'boundstate\mailgun\Mailer',
'key' => 'key-85886fafb248373bd90a396',// valid key
'domain' => 'sandbox5d98013abb1749fd94b68.mailgun.org',//valid domain
],
Now,
when i am using it by,
Yii::$app->mailer->compose()
->setFrom('valid-email-address')
->setTo('valid-email-address')
->setSubject("test mail from mailgun api")
->send();
first , i got issue with SSL for my localhost.
GuzzleHttp\Exception\RequestException
cURL error 60: SSL certificate problem: unable to get local issuer certificate
↵
Caused by: GuzzleHttp\Ring\Exception\RingException
there is no any configuration to set SSL => false through config as we can do with sendgrid extension.
and also i am facing this error after this,
Mailgun\Connection\Exceptions\MissingEndpoint
The endpoint you've tried to access does not exist. Check your URL
In mailgun Api , they are using "api.mailgun.net" ,although it throws such kind of error ..
Is there any solution for these two issues ??
Maybe you can read this issue in github first #130 and #175.
To solve your problem you can manually add this line in your php.ini(based on Comment on that issues)
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\php\extras\cacert.pem"
Or you can use my way, by added it manually with instance Client adapter from guzzle like this. If you want use ssl, you can set verify to false
use Http\Adapter\Guzzle6\Client;
$httpClient = Client::createWithConfig([
'verify' => __DIR__ . '/../config/ca-cert.pem'
]);
$mailgun = new Mailgun(self::$apiKey, $httpClient);

Magento Soap client is not working on https

I have facing issue on Magento soap api connection whenever try to use https as secure url.
My magento system version CE 1.7 and soap version 1.
System Url setup is
Secure url is https://www.example.com/
Unsecured is http://www.example.com/
When i am changed secure to http://www.example.com/(With out https)
Then the soap client is working properly.
Also,when secure is https://www.example.com ,it throw below error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://www.example.com/index.php/api/soap/index/?wsdl' : failed to load external entity "https://www.example.com/index.php/api/soap/index/?wsdl
My code is
try{
$cli = new SoapClient('http://www.example.com/index.php/api/soap/index/?wsdl');
$session = $cli->login('marketplace_usr', 'ezvendorplus');
$result = $cli->call($session, 'catalog_product.info', 10887);
var_dump($result);
}
catch(Exception $e){
echo '<pre>';
var_dump($e);
}
Check is php_openssl extension enabled. If not - enable it.
It is server site issue.Hosting provider is resolved the issue by
add a ssl vhost on private ip for www.example.com and reload apache
and also made a host file entry

Client side ssl certificate using Zend_Http_Client

i've been trying to set up a secure communication using client side certificate between my client application and my server application.
I've set up a the configuration in my apache web server and both in my browser just to make sure that it works and it does.
i'm using zend framework 1.12, and according to the documentation on Zend website
the following example should work:
$config = array( 'sslcert' => 'path/to/ca.crt', 'sslpassphrase' => 'p4ssw0rd');
$adapter = new Zend_Http_Adapter_Socket();
$adapter->setConfig($config);
$http_client = new Zend_Http_Client();
$http_client->setAdapter($adapter);
$http_client->setUri('https://somewhere.overtherainbow.com:1337/bluebird');
$http_client->request();
but everytime i just get the same exception
Unable to Connect to ssl://somewhere.overtherainbow.com:1337
There is no doubt that i'm using the right certificate and passphrase and there is access to the remote machine
so where could be the downfall ?
Sounds like a simple firewall issue - login to the server and stop iptables and then see if it connects. Or add an exception to the clients IP to access mysql. Also check :1337 is open

Categories