title: "Signature does not match" error when importing a certificate into keystore - why?
body: <p>In principle, this is a keytool issue, not anything to do with Shibboleth, but it would probably be helpful to understand where I am trying to get to (skip to the bits in <strong>bold</strong> if the Shibboleth stuff doesn't mean anything to you):</p>
  
  <p>I am trying to set up a Shibboleth SSO configuration. The IdP was already set up, and I have established an SP to talk to it. So far (after much hacking away), so good - the SP (linked into an apache reverse proxy) intercepts calls to secured resources and redirects to the IdP correctly, which presents a login page. After logging in, the IdP replies handing the SP a token.</p>
  
  <p>The SP is then supposed to contact the IdP to get the token translated into attributes valid for the person who logged in, but here the IdP is complaining that the message doesn't meet security requirements.</p>
  
  <p>As best as I can tell, this is because tomcat is not accepting the SP's certificate, which was self-signed.</p>
  
  <p><strong>Instead I am trying to generate a CA cert, and use that to sign the certificate</strong>. I have added the CA cert into $JAVA_HOME/jre/lib/security/cacerts, so keytool should trust it, but then when I try importing the signed SP certificate into the keystore, I get the error:</p>
  
  <p>keytool error: java.security.SignatureException: <strong>Signature does not match.</strong></p>
  
  <p>The import command I am using is:</p>
  
  <p>keytool -import -v -alias sp_signed_cert -keystore idp.jks -trustcacerts -file server.crt</p>
  
  <p>where server.crt is the signed SP certificate.</p>
  
  <p><strong>Why am I getting this error, and what can I do about it?</strong></p>
  
  <p>The only options I seem to have left are:</p>
  
  <ul>
  <li>put apache in front of the Tomcat running the IdP and use its "optional_no_ca" setting to be able to use a self-signed certificate,</li>
  <li>pay for a well-known CA to sign the certificate (not really appropriate for a proof-of-concept, though)</li>
  </ul>