title: Translate Java to Python -- signing strings with PEM certificate files
body: <p>I'm trying to translate the follow Java into its Python equivalent.</p>
  
  <pre><code> // certificate is contents of https://fps.sandbox.amazonaws.com/certs/090909/PKICert.pem
   // signature is a string that I need to verify.
   CertificateFactory factory = CertificateFactory.getInstance("X.509");
   X509Certificate x509Certificate = 
              (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(certificate.getBytes()));
   Signature signatureInstance = Signature.getInstance(signatureAlgorithm);
   signatureInstance.initVerify(x509Certificate.getPublicKey());
   signatureInstance.update(stringToSign.getBytes(UTF_8_Encoding));
   return signatureInstance.verify(Base64.decodeBase64(signature.getBytes()));
  </code></pre>
  
  <p>This is for the PKI signature verification used by AWS FPS. <a href="http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/VerifyingSignature.html" rel="nofollow noreferrer">http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/VerifyingSignature.html</a></p>
  
  <p>Thanks for your help!</p>