Created
          March 14, 2017 17:56 
        
      - 
      
- 
        Save svetlyak40wt/86bc8f7cca378dc17cc0e424e3ebd421 to your computer and use it in GitHub Desktop. 
    This utility prints information about all SSL certificates in one pem file. Useful to see what is inside of certificate chain.
  
        
  
    
      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
    
  
  
    
  | #!/usr/bin/env python | |
| # coding: utf-8 | |
| from __future__ import division, absolute_import | |
| from __future__ import print_function | |
| import sys | |
| import subprocess | |
| def print_cert(cert): | |
| filename = '/tmp/temp.cert' | |
| with open(filename, 'w') as f: | |
| f.write(cert) | |
| command = ['openssl', 'x509', '-in', filename, '-subject', '-issuer', '-noout'] | |
| output = subprocess.check_output(command) | |
| output = output.decode('utf-8') | |
| print(output) | |
| def main(): | |
| filename = sys.argv[1] | |
| with open(filename) as f: | |
| lines = [] | |
| # считываем сертификаты по одному | |
| for line in f: | |
| lines.append(line) | |
| if line == '-----END CERTIFICATE-----\n': | |
| print_cert(''.join(lines)) | |
| lines[:] = [] | |
| if __name__ == '__main__': | |
| main() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Переписать на Lisp? ;)