title: How to force CmsSigner to use RSASSA-PSS (RsaPss) when signing with an X509Certificate with RSA assymetric parameters
body: <p>I am creating signed &amp; encrypted pkcs 7 data.
  The certificates that I use to generate signatures are issued by an external party (goverment agency).</p>
  
  <p>The 'other-side' only supports signatures based on a SHA256 digest, computed using RSASSA-PSS, but CmsSigner (internally used by SignedCms) automatically chooses 'plain RSA'.</p>
  
  <p>Creating an RSASSA-PSS (or RsaPss) signature would not be problem. The issue at hand is that CmsSigner seems to choose the signature algorithm, based on the certificate's key pair algorithm.</p>
  
  <p>Code snippet:</p>
  
  <pre><code>public static byte[] EncryptDotNet(P12Keystore p12KeyStore, byte[] secret, params Etk[] etks)
      {
          if (etks == null || etks?.Any() == false)
          {
              throw new ArgumentNullException(nameof(etks));
          }
  
          var authenticationCertificate = p12KeyStore.AuthenticationCert;
  
          var cmsSigner = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, authenticationCertificate)
          {
              IncludeOption = X509IncludeOption.EndCertOnly,
              DigestAlgorithm = new Oid(oidDigestAlgoSHA256)
          };
  
          var content = new ContentInfo(secret);
          var innerSignedCms = new SignedCms(content);
          innerSignedCms.ComputeSignature(cmsSigner, true);
  
          if (innerSignedCms.SignerInfos[0].SignatureAlgorithm.Value != signatureAlgorithmRSASSAPSS)
          {
              //---&gt; does not comply with expectation.
          }
  </code></pre>
  
  <p>I have tried using reflection to setting the the algorithm oid for RSASSA-PSS to the public/private key of the certificate, didn't seem to have an impact.
  Now I am wondering if I can take the RSA output and do the PSS padding myself?
  Anyhow, I am open to all suggestions...</p>