Tag Archives: ssl

How to scrape a SSL or HTTPS URL

Questions: I have written a function to scrape a website using CURL but it returns nothing when called and can’t understand why. The output is empty <?php function scrape($url) { $headers = Array( “Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5”, “Cache-Control: max-age=0”, “Connection: keep-alive”, “Keep-Alive: 300”, “Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7”, “Accept-Language: en-us,en;q=0.5”, “Pragma: ” ); $config = Array( CURLOPT_RETURNTRANSFER => TRUE ,… Read More »

Amazon MarketplaceWebServiceOrders requests suddenly failing, PHP curl giving SSL CA cert error?

Questions: Starting at 4am Sunday, we suddenly started seeing errors from curl, from the Marketplace Web Service Orders PHP5 Library MarketplaceWebServiceOrders/Client.php script: Caught Exception: Internal Error Response Status Code: 0 Error Code: Error Type: Request ID: XML: ResponseHeaderMetadata: RequestId: , ResponseContext: , Timestamp: The actual curl error number is 77, with the message being: Problem… Read More »

Decrypt string in C# that was encrypted with PHP openssl_encrypt

Questions: I have a customer encrypting a string in PHP with the following code: $password = ‘Ty63rs4aVqcnh2vUqRJTbNT26caRZJ’; $method = ‘AES-256-CBC’; texteACrypter = ‘Whether you think you can, or you think you can\’t–you\’re right. – Henry Ford’; $encrypted = openssl_encrypt($texteACrypter, $method, $password); which results in this encrypted output: MzVWX4tH4yZWc/w75zUagUMEsP34ywSYISsIIS9fj0W3Q/lR0hBrHmdvMOt106PlKhN/1zXFBPbyKmI6nWC5BN54GuGFSjkxfuansJkfoi0= When I try to decrypt that string… Read More »

Why does openssl_pkey_new() fail?

Questions: I’m very new to this. Why is openssl_pkey_new() returning false? I am using XAMPP and there is a an OpenSSL under the Apahce\bin directory. What obvious beginner mistake am I making? Maybe it’s a matter of SSL configuration? My goal is to write the two keys into two files. Update: as suggested, I used… Read More »

php 5.6 ssl certificate verify

Questions: I am trying to debug a problem with ssl certificate verification and have determined that openssl get cert locations with returning incorrect paths. (See below) How do I figure out how to set this? I looked in the php.ini file and couldn’t find this reference anywhere. cmuench-air:bin cmuench$ ./php -r “print_r(openssl_get_cert_locations());” Array ( [default_cert_file]… Read More »

php: mcrypt_encrypt to openssl_encrypt, and OPENSSL_ZERO_PADDING problems

Questions: I have this mcrypt_encrypt call, for a given $key, $message and $iv: $string = mcrypt_encrypt(MCRYPT_3DES, $key, $message, MCRYPT_MODE_CBC, $iv); I’d like to change the mcrypt_encrypt call to an openssl_encrypt one, to future-proof this. By having $mode = ‘des-ede3-cbc’ or $mode = ‘3DES’; and $options = true I get the more similar response, but not… Read More »

APN php code giving Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195

Questions: I am trying to implement Apple Push Notification using php code. Here’s my code $deviceToken = ‘My device token’; $passphrase = ”; $message = ‘My first push notification!’; //////////////////////////////////////////////////////////////////////////////// $ctx = stream_context_create(); stream_context_set_option($ctx, ‘ssl’, ‘local_cert’, ‘apns-dev-cert.pem’); stream_context_set_option($ctx, ‘ssl’, ‘passphrase’, $passphrase); $fp = stream_socket_client( ‘ssl://gateway.sandbox.push.apple.com:2195’, $err, $errstr, 120, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); if (!$fp) exit(“Failed to connect:… Read More »