original_docstring: Generates a configuration profile with a P12 payload containing the given CA P12 data
          and a MCX payload with the ManagedInstalls.plist for the munki_client.
          Returns the XML contents of the config file or None.
docstring: Generates a configuration profile with a P12 payload containing the given CA P12 data
  and a MCX payload with the ManagedInstalls.plist for the munki_client.
  Returns the XML contents of the config file or None.
docstring_tokens: Generates a configuration profile with a P12 payload containing the given CA P12 data and a MCX payload with the ManagedInstalls . plist for the munki_client . Returns the XML contents of the config file or None .
code: def make_mobileconfig(given_serial,given_ca_cert_p12_data,given_ca_cert_cn):
      '''Generates a configuration profile with a P12 payload containing the given CA P12 data
          and a MCX payload with the ManagedInstalls.plist for the munki_client.
          Returns the XML contents of the config file or None.'''
      common.logging_info("Generating configuration profile for %s." % given_serial)
  
      # New profile main dict:
      mobileconfig_top_dict = {}
      mobileconfig_top_dict['PayloadVersion'] = int(1)
      mobileconfig_top_dict['PayloadType'] = "Configuration"
      mobileconfig_top_dict['PayloadScope'] = "System"
      mobileconfig_top_dict['PayloadIdentifier'] = "%s.config.profile.munki-enrollment" % config_site.ORGANIZATION_ID_PREFIX
      mobileconfig_top_dict['PayloadUUID'] = str(uuid.uuid4())
      mobileconfig_top_dict['PayloadOrganization'] = config_munki_client.CONFIG_PROFILE_ORG
      mobileconfig_top_dict['PayloadDisplayName'] = config_munki_client.CONFIG_PROFILE_DISPLAY_NAME
      mobileconfig_top_dict['PayloadDescription'] = config_munki_client.CONFIG_PROFILE_DESCRIPTION
      mobileconfig_top_dict['PayloadContent'] = [] # This is an array of other dicts.
  
      
      # P12 CA Payload:
      payload_p12_dict = {}
      payload_p12_dict['PayloadVersion'] = int(1)
      payload_p12_dict['PayloadType'] = "com.apple.security.pkcs12"
      payload_p12_dict['PayloadUUID'] = str(uuid.uuid4())
      payload_p12_dict['PayloadIdentifier'] = "%s.config.payload.com.apple.security.pkcs12.ca-cert" % config_site.ORGANIZATION_ID_PREFIX
      payload_p12_dict['PayloadDisplayName'] = config_munki_client.P12_CA_DISPLAY_NAME
      payload_p12_dict['PayloadDescription'] = "CA: %s" % given_ca_cert_cn
      payload_p12_dict['PayloadContent'] = plistlib.Data(given_ca_cert_p12_data)
      payload_p12_dict['Password'] = given_serial
      mobileconfig_top_dict['PayloadContent'].append(payload_p12_dict)
      p12_server_ca = None
  
      # Munki client prefs start with template file read by our configuration:
      mcx_preference_settings = config_munki_client.MUNKI_CLIENT_PREFS_DICT
      # Test for mandatory keys:
      for key in config_munki_client.MUNKI_CLIENT_MANDATORY_KEYS:
          try:
              value = mcx_preference_settings[key]
          except KeyError:
              return None
      # Add key overrides:
      mcx_preference_settings['UseClientCertificate'] = True
      mcx_preference_settings['UseClientCertificateCNAsClientIdentifier'] = False
      mcx_preference_settings['ClientIdentifier'] = 'computers/%s' % given_serial.upper()
      # Random password for the Munki keychain:
      mcx_preference_settings['KeychainPassword'] = str(uuid.uuid4()).replace('-','')
      # Set the keychain name so that it's clear it can be removed as long as the
      # client's identity PEM file is present.
      mcx_preference_settings['KeychainName'] = "munki-temp.keychain"
      
      # Munki config profile payload:
      payload_mcx_munki_client_dict = {}
      payload_mcx_munki_client_dict['PayloadVersion'] = int(1)
      payload_mcx_munki_client_dict['PayloadType'] = "com.apple.ManagedClient.preferences"
      payload_mcx_munki_client_dict['PayloadUUID'] = str(uuid.uuid4())
      payload_mcx_munki_client_dict['PayloadIdentifier'] = "%s.config.payload.com.apple.ManagedClient.preferences.munki" % config_site.ORGANIZATION_ID_PREFIX
      payload_mcx_munki_client_dict['PayloadDisplayName'] = config_munki_client.MUNKI_MCX_PAYLOAD_DISPLAY_NAME
      payload_mcx_munki_client_dict['PayloadDescription'] = "Server: %s" % mcx_preference_settings['SoftwareRepoURL'].replace('https://','').replace('/','')
      payload_mcx_munki_client_dict['PayloadContent'] = {}
      payload_mcx_munki_client_dict['PayloadContent'][config_munki_client.MUNKI_MCX_DEFAULTS_DOMAIN] = {}
      payload_mcx_munki_client_dict['PayloadContent'][config_munki_client.MUNKI_MCX_DEFAULTS_DOMAIN]['Forced'] = [{}]
      payload_mcx_munki_client_dict['PayloadContent'][config_munki_client.MUNKI_MCX_DEFAULTS_DOMAIN]['Forced'][0]['mcx_preference_settings'] = mcx_preference_settings
      mobileconfig_top_dict['PayloadContent'].append(payload_mcx_munki_client_dict)
  
      # Return XML of the mobileconfig:
      try:
          return plistlib.writePlistToString(mobileconfig_top_dict)
      except xml.parsers.expat.ExpatError:
          return None
      except TypeError:
          return None
code_tokens: def make_mobileconfig ( given_serial , given_ca_cert_p12_data , given_ca_cert_cn ) : common . logging_info ( "Generating configuration profile for %s." % given_serial ) mobileconfig_top_dict = { } mobileconfig_top_dict [ 'PayloadVersion' ] = int ( 1 ) mobileconfig_top_dict [ 'PayloadType' ] = "Configuration" mobileconfig_top_dict [ 'PayloadScope' ] = "System" mobileconfig_top_dict [ 'PayloadIdentifier' ] = "%s.config.profile.munki-enrollment" % config_site . ORGANIZATION_ID_PREFIX mobileconfig_top_dict [ 'PayloadUUID' ] = str ( uuid . uuid4 ( ) ) mobileconfig_top_dict [ 'PayloadOrganization' ] = config_munki_client . CONFIG_PROFILE_ORG mobileconfig_top_dict [ 'PayloadDisplayName' ] = config_munki_client . CONFIG_PROFILE_DISPLAY_NAME mobileconfig_top_dict [ 'PayloadDescription' ] = config_munki_client . CONFIG_PROFILE_DESCRIPTION mobileconfig_top_dict [ 'PayloadContent' ] = [ ] payload_p12_dict = { } payload_p12_dict [ 'PayloadVersion' ] = int ( 1 ) payload_p12_dict [ 'PayloadType' ] = "com.apple.security.pkcs12" payload_p12_dict [ 'PayloadUUID' ] = str ( uuid . uuid4 ( ) ) payload_p12_dict [ 'PayloadIdentifier' ] = "%s.config.payload.com.apple.security.pkcs12.ca-cert" % config_site . ORGANIZATION_ID_PREFIX payload_p12_dict [ 'PayloadDisplayName' ] = config_munki_client . P12_CA_DISPLAY_NAME payload_p12_dict [ 'PayloadDescription' ] = "CA: %s" % given_ca_cert_cn payload_p12_dict [ 'PayloadContent' ] = plistlib . Data ( given_ca_cert_p12_data ) payload_p12_dict [ 'Password' ] = given_serial mobileconfig_top_dict [ 'PayloadContent' ] . append ( payload_p12_dict ) p12_server_ca = None mcx_preference_settings = config_munki_client . MUNKI_CLIENT_PREFS_DICT for key in config_munki_client . MUNKI_CLIENT_MANDATORY_KEYS : try : value = mcx_preference_settings [ key ] except KeyError : return None mcx_preference_settings [ 'UseClientCertificate' ] = True mcx_preference_settings [ 'UseClientCertificateCNAsClientIdentifier' ] = False mcx_preference_settings [ 'ClientIdentifier' ] = 'computers/%s' % given_serial . upper ( ) mcx_preference_settings [ 'KeychainPassword' ] = str ( uuid . uuid4 ( ) ) . replace ( '-' , '' ) mcx_preference_settings [ 'KeychainName' ] = "munki-temp.keychain" payload_mcx_munki_client_dict = { } payload_mcx_munki_client_dict [ 'PayloadVersion' ] = int ( 1 ) payload_mcx_munki_client_dict [ 'PayloadType' ] = "com.apple.ManagedClient.preferences" payload_mcx_munki_client_dict [ 'PayloadUUID' ] = str ( uuid . uuid4 ( ) ) payload_mcx_munki_client_dict [ 'PayloadIdentifier' ] = "%s.config.payload.com.apple.ManagedClient.preferences.munki" % config_site . ORGANIZATION_ID_PREFIX payload_mcx_munki_client_dict [ 'PayloadDisplayName' ] = config_munki_client . MUNKI_MCX_PAYLOAD_DISPLAY_NAME payload_mcx_munki_client_dict [ 'PayloadDescription' ] = "Server: %s" % mcx_preference_settings [ 'SoftwareRepoURL' ] . replace ( 'https://' , '' ) . replace ( '/' , '' ) payload_mcx_munki_client_dict [ 'PayloadContent' ] = { } payload_mcx_munki_client_dict [ 'PayloadContent' ] [ config_munki_client . MUNKI_MCX_DEFAULTS_DOMAIN ] = { } payload_mcx_munki_client_dict [ 'PayloadContent' ] [ config_munki_client . MUNKI_MCX_DEFAULTS_DOMAIN ] [ 'Forced' ] = [ { } ] payload_mcx_munki_client_dict [ 'PayloadContent' ] [ config_munki_client . MUNKI_MCX_DEFAULTS_DOMAIN ] [ 'Forced' ] [ 0 ] [ 'mcx_preference_settings' ] = mcx_preference_settings mobileconfig_top_dict [ 'PayloadContent' ] . append ( payload_mcx_munki_client_dict ) try : return plistlib . writePlistToString ( mobileconfig_top_dict ) except xml . parsers . expat . ExpatError : return None except TypeError : return None
short_docstring: Generates a configuration profile with a P12 payload containing the given CA P12 data
  and a MCX payload with the ManagedInstalls.plist for the munki_client.
short_docstring_tokens: Generates a configuration profile with a P12 payload containing the given CA P12 data and a MCX payload with the ManagedInstalls . plist for the munki_client .
comment: '''Generates a configuration profile with a P12 payload containing the given CA P12 data
          and a MCX payload with the ManagedInstalls.plist for the munki_client.
          Returns the XML contents of the config file or None.'''$SEP$# New profile main dict:$SEP$# This is an array of other dicts.$SEP$# P12 CA Payload:$SEP$# Munki client prefs start with template file read by our configuration:$SEP$# Test for mandatory keys:$SEP$# Add key overrides:$SEP$# Random password for the Munki keychain:$SEP$# Set the keychain name so that it's clear it can be removed as long as the$SEP$# client's identity PEM file is present.$SEP$# Munki config profile payload:$SEP$# Return XML of the mobileconfig: