def _list_certs(certificatestore='My'):
 ret = dict()
 pscmd = list()
 blacklist_keys = ['DnsNameList', 'Thumbprint']
 cert_path = 'Cert:\\LocalMachine\\{0}'.format(certificatestore)
 pscmd.append("Get-ChildItem -Path '{0}' | Select-Object".format(cert_path))
 pscmd.append(' DnsNameList, SerialNumber, Subject, Thumbprint, Version')
 cmd_ret = _srvmgr(func=str().join(pscmd), as_json=True)
 try:
  items = json.loads(cmd_ret['stdout'], strict=False)
 except ValueError:
  _LOG.error('Unable to parse return data as Json.')
 for item in items:
  cert_info = dict()
  for key in item:
   if (key not in blacklist_keys):
    cert_info[key.lower()] = item[key]
  cert_info['dnsnames'] = [name['Unicode'] for name in item['DnsNameList']]
  ret[item['Thumbprint']] = cert_info
 return ret

def _list_certs ( certificatestore = 'My' ) : ret = dict ( ) pscmd = list ( ) blacklist_keys = [ 'DnsNameList' , 'Thumbprint' ] cert_path = 'Cert:\\LocalMachine\\{0}' . format ( certificatestore ) pscmd . append ( "Get-ChildItem -Path '{0}' | Select-Object" . format ( cert_path ) ) pscmd . append ( ' DnsNameList, SerialNumber, Subject, Thumbprint, Version' ) cmd_ret = _srvmgr ( func = str ( ) . join ( pscmd ) , as_json = True ) try : items = json . loads ( cmd_ret [ 'stdout' ] , strict = False ) except ValueError : _LOG . error ( 'Unable to parse return data as Json.' ) for item in items : cert_info = dict ( ) for key in item : if ( key not in blacklist_keys ) : cert_info [ key . lower ( ) ] = item [ key ] cert_info [ 'dnsnames' ] = [ name [ 'Unicode' ] for name in item [ 'DnsNameList' ] ] ret [ item [ 'Thumbprint' ] ] = cert_info return ret
list details of available certificates .