Advertisement
urosevic

WordPress: Test wp_remote_get() w/ and w/o sslverify

Feb 20th, 2016
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Put file test_ssl.php to WP root and open it in browser.
  4.  * If you get some error about SSL in green block:
  5.  * * SSL connection timeout - can be temporary issue with remote website or local server firewall (blocked connection with remote host)
  6.  * * SSL: CA certificate set, but certificate verification is disabled - enable SSL verifycation in Apache
  7.  */
  8.  
  9. /* Initiate WordPress */
  10. define( 'WP_USE_THEMES', false );
  11. require( './wp-blog-header.php' );
  12.  
  13. /* Define HTTPS URL to test */
  14. $url = 'https://www.googleapis.com/youtube/v3/playlistItems';
  15.  
  16. /* Request URL with and w/o SSL verify */
  17. $res_sslverify = wp_remote_get( $url );
  18. $res_nosslverify = wp_remote_get( $url, array( 'sslverify' => false ) );
  19.  
  20. /* Print output */
  21. printf(
  22.     '%s<br><pre class="verify">Verified SSL:<br/>%s</pre><pre class="noverify">Not verified SSL:<br/>%s</pre>',
  23.     $url,
  24.     print_r( $res_sslverify, 1 ),
  25.     print_r( $res_nosslverify, 1 )
  26. );
  27. ?>
  28. <style>
  29. pre { width:50%; float:left; padding: 5px; box-sizing:border-box;}
  30. .verify { background: green; }
  31. .noverify { background: red; }
  32. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement