forked from Sustainsys/Saml2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client certificates for artifact resolve
- Fixes Sustainsys#367 - Closes Sustainsys#716 - Closes Sustainsys#789
- Loading branch information
Showing
11 changed files
with
268 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Text; | ||
|
||
namespace Sustainsys.Saml2.Internal | ||
{ | ||
/// <summary> | ||
/// A WebClient implementation that will add a list of client | ||
/// certificates to the requests it makes. | ||
/// </summary> | ||
internal class ClientCertificateWebClient : WebClient | ||
{ | ||
private readonly IEnumerable<X509Certificate2> certificates; | ||
/// <summary> | ||
/// Register the certificate to be used for this requets. | ||
/// </summary> | ||
/// <param name="certificates">Certificates to offer to server</param> | ||
public ClientCertificateWebClient(IEnumerable<X509Certificate2> certificates) | ||
{ | ||
this.certificates = certificates; | ||
} | ||
/// <summary> | ||
/// Override the base class to add the certificate | ||
/// to the reuqest before returning it. | ||
/// </summary> | ||
/// <param name="address"></param> | ||
/// <returns></returns> | ||
protected override WebRequest GetWebRequest(Uri address) | ||
{ | ||
var request = (HttpWebRequest)base.GetWebRequest(address); | ||
if (certificates != null) | ||
{ | ||
foreach(var c in certificates) | ||
{ | ||
request.ClientCertificates.Add(c); | ||
} | ||
} | ||
return request; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.