(self, certificate, private_key)
Adds a machine certificate payload to the profile.

    Args:
      certificate: str, PEM-formatted certificate.
      private_key: str, PEM-formatted private key.

    Raises:
      CertificateError: there was an error processing the certificate/key
Adds a machine certificate payload to the profile.
Adds a machine certificate payload to the profile .
def AddMachineCertificate(self, certificate, private_key):
    """Adds a machine certificate payload to the profile.

    Args:
      certificate: str, PEM-formatted certificate.
      private_key: str, PEM-formatted private key.

    Raises:
      CertificateError: there was an error processing the certificate/key
    """
    try:
      cert = certs.Certificate(certificate)

      pkcs12 = crypto.PKCS12Type()
      pkcs12.set_certificate(crypto.load_certificate(
          crypto.FILETYPE_PEM, certificate))
      pkcs12.set_privatekey(crypto.load_privatekey(
          crypto.FILETYPE_PEM, private_key))
    except (certs.CertError, crypto.Error) as e:
      raise CertificateError(e)

    payload = {PAYLOADKEYS_IDENTIFIER: self._GenerateID('machine_cert'),
               PAYLOADKEYS_TYPE: 'com.apple.security.pkcs12',
               PAYLOADKEYS_DISPLAYNAME: cert.subject_cn,
               'Password': cert.osx_fingerprint}

    try:
      payload[PAYLOADKEYS_CONTENT] = plistlib.Data(
          pkcs12.export(cert.osx_fingerprint))
    except crypto.Error as e:
      raise CertificateError(e)

    # Validate payload to generate its UUID
    ValidatePayload(payload)
    self._auth_cert = payload.get(PAYLOADKEYS_UUID)
    self.AddPayload(payload)
def AddMachineCertificate ( self , certificate , private_key ) : try : cert = certs . Certificate ( certificate ) pkcs12 = crypto . PKCS12Type ( ) pkcs12 . set_certificate ( crypto . load_certificate ( crypto . FILETYPE_PEM , certificate ) ) pkcs12 . set_privatekey ( crypto . load_privatekey ( crypto . FILETYPE_PEM , private_key ) ) except ( certs . CertError , crypto . Error ) as e : raise CertificateError ( e ) payload = { PAYLOADKEYS_IDENTIFIER : self . _GenerateID ( 'machine_cert' ) , PAYLOADKEYS_TYPE : 'com.apple.security.pkcs12' , PAYLOADKEYS_DISPLAYNAME : cert . subject_cn , 'Password' : cert . osx_fingerprint } try : payload [ PAYLOADKEYS_CONTENT ] = plistlib . Data ( pkcs12 . export ( cert . osx_fingerprint ) ) except crypto . Error as e : raise CertificateError ( e ) # Validate payload to generate its UUID ValidatePayload ( payload ) self . _auth_cert = payload . get ( PAYLOADKEYS_UUID ) self . AddPayload ( payload )