2017-01-12 10 views
2

私は、saml 2.0 AuthnRequestを生成してSamlResponseを消費するネイティブc#コードを使用するサービスプロバイダです。クライアントは、私たちにsaml AuthnRequestに署名し、それをそれらに送信するように依頼しました。私たちはhttp-POSTとして送信しています。C#でsaml 2.0 authnrequestに署名する方法

  1. 彼らのx509証明書を含むIDPのメタデータ: ここで私たちが持っているデータがあります。

  2. 私たち自身のx509証明書と秘密鍵。自己を取得するには、このツールを使用し当社独自のSPのメタデータ(エンティティ記述子は)上記で、今、このツールhttps://www.samltool.com/sp_metadata.php

を使用して、自己署名証明書と秘密鍵を使って署名された1 https://www.samltool.com/self_signed_certs.php

  • を締結情報、私はどのように私のAuthnRequestに署名するのですか?

  • 答えて

    1

    asp.netとmvcの究極のsamlライブラリを使用すると、AuthnRequestに簡単に署名できます。

    AuthnRequestオブジェクトを作成し、Signメソッドを呼び出すだけで、この例を参照してください。 Ultimate saml library for asp.net and mvc

    // Create a new instance of the AuthnRequest class. 
    AuthnRequest request = new AuthnRequest(); 
    request.IsPassive = false; 
    // Set Protocol Binding. 
    request.ProtocolBinding = SamlBindingUri.HttpPost; 
    // Set the target provider's Assertion Consumer Service Url. 
    request.AssertionConsumerServiceUrl = "your url"; 
    
    // Set Issuer 
    request.Issuer = new Issuer(); 
    request.Issuer.NameIdentifier = "your name identifier"; 
    
    request.NameIdPolicy = new NameIdPolicy(); 
    request.NameIdPolicy.SpNameQualifier = "moodle.sp.myname"; 
    request.NameIdPolicy.AllowCreate = true; 
    request.NameIdPolicy.Format = SamlNameIdentifierFormat.Persistent; 
    
    request.RequestedAuthnContext = new RequestedAuthnContext(); 
    request.RequestedAuthnContext.Comparison = SamlAuthenticationContextComparison.Exact; 
    request.RequestedAuthnContext.AuthenticationContexts.Add(new AuthnContextClassRef(SamlAuthenticationContext.PasswordProtectedTransport)); 
    
    // Send the request over HTTP POST 
    request.SendHttpPost(Response, "http://mybaseurl", "my_relay_state"); 
    
    // Or you can send it over HTTP Redirect 
    // X509Certificate2 certificate = new X509Certificate2("PKey.pfx", "password"); 
    // request.Redirect(Response, "http://mybaseurl", "my_relay_state", certificate.PrivateKey); 
    
    関連する問題