Created
          November 25, 2016 01:18 
        
      - 
      
- 
        Save IlariExove/a8cfe7ef39569d3b4f0cc35dc53bb854 to your computer and use it in GitHub Desktop. 
    How to debug PHP cURL SSL/TLS parameters
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| $ch = curl_init('https://www.google.com/'); | |
| $verbose = fopen('php://temp', 'w+'); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
| curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); | |
| curl_setopt($ch, CURLOPT_VERBOSE, TRUE); | |
| curl_setopt($ch, CURLOPT_STDERR, $verbose); | |
| curl_exec($ch); | |
| curl_close($ch); | |
| rewind($verbose); | |
| $stderr_lines = explode("\n", stream_get_contents($verbose)); | |
| $tls_nego = array(); | |
| foreach($stderr_lines as $line) | |
| { | |
| if (preg_match_all('/^\* Connected to (.*) \(.* port (.*) \(.*$/', $line, $matches) != 0) | |
| { | |
| $server = $matches[1][0] . ':' . $matches[2][0]; | |
| } | |
| if (preg_match_all('/^\* (.*) connection using (.*)$/', $line, $matches) != 0) | |
| { | |
| $tls_nego[$server] = array($matches[1][0], $matches[2][0]); | |
| } | |
| } | |
| print_r($tls_nego); | 
      
      
  Author
  
  
        
      
            IlariExove
  
      
      
      commented 
        Nov 25, 2016 
      
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment