(issuer_cn, service, keychain=login_keychain)
Create a TLS Identity preference for a given cert.

  Args:
    issuer_cn: str, CN of issuer of cert to create preference for
    service: str, Service for which identity should be preferred
    keychain: str, keychain to create the preference entry in

  Raises:
    CertError: if there is more than one matching cert
    CertError: if the preference can't be created
Create a TLS Identity preference for a given cert.
Create a TLS Identity preference for a given cert .
def CreateIdentityPreference(issuer_cn, service, keychain=login_keychain):
  """Create a TLS Identity preference for a given cert.

  Args:
    issuer_cn: str, CN of issuer of cert to create preference for
    service: str, Service for which identity should be preferred
    keychain: str, keychain to create the preference entry in

  Raises:
    CertError: if there is more than one matching cert
    CertError: if the preference can't be created
  """
  logging.debug('Creating TLS identity preference for %s in keychain %s',
                service, keychain)

  existing_certs = FindCertificates(issuer_cn=issuer_cn, keychain=keychain)
  if len(existing_certs) != 1:
    raise CertError('More or less than one matching certificate '
                    'in the keychain.')

  command = [CMD_SECURITY, 'set-identity-preference', '-Z',
             existing_certs[0].osx_fingerprint, '-s', service, keychain]
  logging.debug('Command: %s', command)
  (stdout, stderr, status) = gmacpyutil.RunProcess(command)
  logging.debug('Identity preference creation output: %s', stdout)
  if status:
    raise CertError(stdout, stderr)
def CreateIdentityPreference ( issuer_cn , service , keychain = login_keychain ) : logging . debug ( 'Creating TLS identity preference for %s in keychain %s' , service , keychain ) existing_certs = FindCertificates ( issuer_cn = issuer_cn , keychain = keychain ) if len ( existing_certs ) != 1 : raise CertError ( 'More or less than one matching certificate ' 'in the keychain.' ) command = [ CMD_SECURITY , 'set-identity-preference' , '-Z' , existing_certs [ 0 ] . osx_fingerprint , '-s' , service , keychain ] logging . debug ( 'Command: %s' , command ) ( stdout , stderr , status ) = gmacpyutil . RunProcess ( command ) logging . debug ( 'Identity preference creation output: %s' , stdout ) if status : raise CertError ( stdout , stderr )