@@ -24,14 +24,14 @@ protected override Saml2RedirectBinding BindInternal(Saml2Request saml2RequestRe
2424 {
2525 base . BindInternal ( saml2RequestResponse ) ;
2626
27- if ( saml2RequestResponse . Config . SigningCertificate != null )
27+ if ( ! ( saml2RequestResponse is Saml2AuthnRequest ) && saml2RequestResponse . Config . SigningCertificate != null )
2828 {
2929 Cryptography . SignatureAlgorithm . ValidateAlgorithm ( saml2RequestResponse . Config . SignatureAlgorithm ) ;
3030 SignatureAlgorithm = saml2RequestResponse . Config . SignatureAlgorithm ;
3131 }
3232
33- var requestQueryString = string . Join ( "&" , RequestQueryString ( saml2RequestResponse . Config . SigningCertificate , messageName ) ) ;
34- if ( saml2RequestResponse . Config . SigningCertificate != null )
33+ var requestQueryString = string . Join ( "&" , RequestQueryString ( saml2RequestResponse , messageName ) ) ;
34+ if ( ! ( saml2RequestResponse is Saml2AuthnRequest ) && saml2RequestResponse . Config . SigningCertificate != null )
3535 {
3636 requestQueryString = SigneQueryString ( requestQueryString , saml2RequestResponse . Config . SigningCertificate ) ;
3737 }
@@ -40,7 +40,7 @@ protected override Saml2RedirectBinding BindInternal(Saml2Request saml2RequestRe
4040
4141 return this ;
4242 }
43-
43+
4444 private string SigneQueryString ( string queryString , X509Certificate2 signingCertificate )
4545 {
4646 var saml2Signed = new Saml2SignedText ( signingCertificate , SignatureAlgorithm ) ;
@@ -49,7 +49,7 @@ private string SigneQueryString(string queryString, X509Certificate2 signingCert
4949 return string . Join ( "&" , queryString , string . Join ( "=" , Saml2Constants . Message . Signature , Uri . EscapeDataString ( Signature ) ) ) ;
5050 }
5151
52- private IEnumerable < string > RequestQueryString ( X509Certificate2 signingCertificate , string messageName )
52+ private IEnumerable < string > RequestQueryString ( Saml2Request saml2RequestResponse , string messageName )
5353 {
5454 yield return string . Join ( "=" , messageName , Uri . EscapeDataString ( CompressRequest ( ) ) ) ;
5555
@@ -58,7 +58,7 @@ private IEnumerable<string> RequestQueryString(X509Certificate2 signingCertifica
5858 yield return string . Join ( "=" , Saml2Constants . Message . RelayState , Uri . EscapeDataString ( RelayState ) ) ;
5959 }
6060
61- if ( signingCertificate != null )
61+ if ( ! ( saml2RequestResponse is Saml2AuthnRequest ) && saml2RequestResponse . Config . SigningCertificate != null )
6262 {
6363 yield return string . Join ( "=" , Saml2Constants . Message . SigAlg , Uri . EscapeDataString ( SignatureAlgorithm ) ) ;
6464 }
@@ -88,12 +88,13 @@ protected override Saml2Request UnbindInternal(HttpRequest request, Saml2Request
8888 if ( ! request . Query . AllKeys . Contains ( messageName ) )
8989 throw new Saml2BindingException ( "HTTP Query String does not contain " + messageName ) ;
9090
91- if ( saml2RequestResponse . Config . SignatureValidationCertificates != null && saml2RequestResponse . Config . SignatureValidationCertificates . Count ( ) > 0 )
91+ if ( ! ( saml2RequestResponse is Saml2AuthnRequest ) &&
92+ saml2RequestResponse . Config . SignatureValidationCertificates != null && saml2RequestResponse . Config . SignatureValidationCertificates . Count ( ) > 0 )
9293 {
93- if ( ! request . Query . AllKeys . Contains ( Saml2Constants . Message . Signature ) )
94+ if ( ! request . Query . AllKeys . Contains ( Saml2Constants . Message . Signature ) )
9495 throw new Saml2BindingException ( "HTTP Query String does not contain " + Saml2Constants . Message . Signature ) ;
9596
96- if ( ! request . Query . AllKeys . Contains ( Saml2Constants . Message . SigAlg ) )
97+ if ( ! request . Query . AllKeys . Contains ( Saml2Constants . Message . SigAlg ) )
9798 throw new Saml2BindingException ( "HTTP Query String does not contain " + Saml2Constants . Message . SigAlg ) ;
9899 }
99100
@@ -102,7 +103,8 @@ protected override Saml2Request UnbindInternal(HttpRequest request, Saml2Request
102103 RelayState = request . Query [ Saml2Constants . Message . RelayState ] ;
103104 }
104105
105- if ( saml2RequestResponse . Config . SignatureValidationCertificates != null && saml2RequestResponse . Config . SignatureValidationCertificates . Count ( ) > 0 )
106+ if ( ! ( saml2RequestResponse is Saml2AuthnRequest ) &&
107+ saml2RequestResponse . Config . SignatureValidationCertificates != null && saml2RequestResponse . Config . SignatureValidationCertificates . Count ( ) > 0 )
106108 {
107109 var actualAignatureAlgorithm = request . Query [ Saml2Constants . Message . SigAlg ] ;
108110 if ( saml2RequestResponse . Config . SignatureAlgorithm == null )
0 commit comments