moltin / php-sdk

Community built SDK for using Moltin with PHP
MIT License
47 stars 19 forks source link

Unknown SSL protocol error in connection to api.moltin.com:443 #56

Closed promijn closed 7 years ago

promijn commented 7 years ago

I'm trying to setup a connection to the api but I get this error

Unknown SSL protocol error in connection to api.moltin.com:443

This is the code I use:

$config = array(
    'client_id'        => '{my _client_id}',
    'client_secret'    => '{my_client_secret}',
    'currency_code'    => 'USD',
    'language'         => 'en',
    'locale'           => 'en_gb',
    'cookie_cart_name' => 'moltin_cart_reference',
    'cookie_lifetime'  => '+28 days'
);
$moltin = new Moltin\Client( $config );
$response           = $moltin->products->all();
$products           = $response->data();
$this->data['item'] = $products;
andrew-waters commented 7 years ago

Hi @promijn, can you send over some information about your environment and the output of php info() - the SSL cert is valid and current. Any extra debug info would be useful.

andrew-waters commented 7 years ago

Also, can you execute the following from the same server/environment, and forward the output:

curl https://api.moltin.com

promijn commented 7 years ago

This is the curl output {"status":true,"message":"Welcome to the Moltin API, for help visit https:\/\/docs.moltin.com\/"}

andrew-waters commented 7 years ago

OK well that looks promising - no errors - any chance you can send over your PHP info output

promijn commented 7 years ago

It's a local setup (MAMP)

System Darwin iMac-van-Paul.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64 Build Date Jul 6 2015 13:53:24 Configure Command './configure' '--with-mysql=mysqlnd' '--with-apxs2=/Applications/MAMP/Library/bin/apxs' '--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library' '--with-png-dir=/Applications/MAMP/Library' '--with-zlib' '--with-zlib-dir=/Applications/MAMP/Library' '--with-freetype-dir=/Applications/MAMP/Library' '--prefix=/Applications/MAMP/bin/php/php5.6.10' '--exec-prefix=/Applications/MAMP/bin/php/php5.6.10' '--sysconfdir=/Applications/MAMP/bin/php/php5.6.10/conf' '--with-config-file-path=/Applications/MAMP/bin/php/php5.6.10/conf' '--enable-ftp' '--enable-gd-native-ttf' '--with-bz2=/usr' '--with-ldap' '--with-mysqli=mysqlnd' '--with-t1lib=/Applications/MAMP/Library' '--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2007f' '--enable-soap' '--with-kerberos' '--enable-calendar' '--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-exif' '--with-libxml-dir=/Applications/MAMP/Library' '--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg' '--with-mcrypt=shared,/Applications/MAMP/Library' '--with-openssl' '--enable-zip' '--with-iconv=/Applications/MAMP/Library' '--enable-opcache' '--enable-intl' '--with-tidy=shared' '--with-icu-dir=/Applications/MAMP/Library' '--enable-wddx' '--with-libexpat-dir=/Applications/MAMP/Library' '--with-readline' 'CFLAGS=-arch 'LDFLAGS=-arch 'LIBS=-lresolv' 'CXXFLAGS=-arch Server API Apache 2.0 Handler Virtual Directory Support disabled Configuration File (php.ini) Path /Applications/MAMP/bin/php/php5.6.10/conf Loaded Configuration File /Library/Application Support/appsolute/MAMP PRO/conf/php.ini Scan this dir for additional .ini files (none) Additional .ini files parsed (none) PHP API 20131106 PHP Extension 20131226 Zend Extension 220131226 Zend Extension Build API220131226,NTS PHP Extension Build API20131226,NTS Debug Build no Thread Safety disabled Zend Signal Handling disabled Zend Memory Manager enabled Zend Multibyte Support provided by mbstring IPv6 Support enabled DTrace Support disabled Registered PHP Streams https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0 Registered Stream Filters zlib., bzip2., convert.iconv., string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consumed, dechunk, mcrypt., mdecrypt.

promijn commented 7 years ago

cURL support enabled cURL Information 7.43.0 Age 3 Features AsynchDNS No CharConv No Debug No GSS-Negotiate No IDN Yes IPv6 Yes krb4 No Largefile Yes libz Yes NTLM Yes NTLMWB Yes SPNEGO No SSL Yes SSPI No TLS-SRP No Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, smb, smbs, smtp, smtps, telnet, tftp Host x86_64-apple-darwin10.8.0 SSL Version OpenSSL/0.9.8zd ZLib Version 1.2.8

andrew-waters commented 7 years ago

I think this is an issue with MAMP - there are similar issues in other SDK's including PayPal.

The problem will stem from the OpenSSL version (0.9.8zd in your case). I'm assuming that you are using a MAMP version < 4.

See here for a potential workaround...

outrunthewolf commented 7 years ago

This could be your local version of OpenSSL not compatible with our load balancers. We support:

TLS 1.2, 1.1

promijn commented 7 years ago

Yes I'm still using MAPM 3.5.2 due some issues with MAMP 4.

andrew-waters commented 7 years ago

OK, I'm confident that's your issue. I'm going to close this issue because it's not the SDK causing the error. If you can you explore the workaround I've linked to and reopen this issue if if you feel that the issue isn't with your OpenSSL version and we'll see if we can help some more.

promijn commented 7 years ago

Switch to MAMP 4 again and this fixed the issue. Thanks for your help!