code: def gen_keys(keysize=2048):
      '''
      Generate Salt minion keys and return them as PEM file strings
      '''
      # Mandate that keys are at least 2048 in size
      if keysize < 2048:
          keysize = 2048
      tdir = tempfile.mkdtemp()
  
      salt.crypt.gen_keys(tdir, 'minion', keysize)
      priv_path = os.path.join(tdir, 'minion.pem')
      pub_path = os.path.join(tdir, 'minion.pub')
      with salt.utils.files.fopen(priv_path) as fp_:
          priv = salt.utils.stringutils.to_unicode(fp_.read())
      with salt.utils.files.fopen(pub_path) as fp_:
          pub = salt.utils.stringutils.to_unicode(fp_.read())
      shutil.rmtree(tdir)
      return priv, puf gen_keys(keysize=2048):
      '''
      Generate Salt minion keys and return them as PEM file strings
      '''
      # Mandate that keys are at least 2048 in size
      if keysize < 2048:
          keysize = 2048
      tdir = tempfile.mkdtemp()
  
      salt.crypt.gen_keys(tdir, 'minion', keysize)
      priv_path = os.path.join(tdir, 'minion.pem')
      pub_path = os.path.join(tdir, 'minion.pub')
      with salt.utils.files.fopen(priv_path) as fp_:
          priv = salt.utils.stringutils.to_unicode(fp_.read())
      with salt.utils.files.fopen(pub_path) as fp_:
          pub = salt.utils.stringutils.to_unicode(fp_.read())
      shutil.rmtree(tdir)
      return priv, pub
docs: Generate Salt minion keys and return them as PEM file strings