Skip to content

Commit

Permalink
#35 - Added support for encrypted assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Havagan committed Aug 26, 2023
1 parent dfa211c commit 25cf07b
Show file tree
Hide file tree
Showing 5 changed files with 787 additions and 530 deletions.
1 change: 1 addition & 0 deletions AspNetSaml.Tests/AspNetSaml.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Shouldly" Version="4.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
107 changes: 107 additions & 0 deletions AspNetSaml.Tests/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System.Security.Cryptography.X509Certificates;

namespace AspNetSaml.Tests;

public static class Constants
{
/// <summary>
/// Test certificate values.
/// </summary>
/// <remarks>
/// Self-signed certificates generated by https://www.samltool.com/self_signed_certs.php.
/// </remarks>
public static class Certificates
{
public const string Country = "US";
public const string State = "New York";
public const string Locality = "New York City";
public const string Organization = "AspNetSaml";
public const string Domain = "aspnetsaml.jitbit.local";
public const string DigestAlgorithm = "SHA512";

/// <summary>
/// Private key raw text.
/// </summary>
public const string PrivateKey = @"-----BEGIN PRIVATE KEY-----
MIIEwgIBADANBgkqhkiG9w0BAQEFAASCBKwwggSoAgEAAoIBAgDb+eVLX3/pcYbX
gustW1YSSTIe737KuJqL9CxibjL2jaEXvoM0zllwYdyvWdrnoJ8tABoKHPtSGRJv
6fH7+cq31zLj50R6Wz4uzdZr37opBdk5ea0YHeaOOmNu1ikfFNMaT0VXuj9kqod8
V/N0Qv77eDaixOivV2nnXGxrgYh/m9dKrr5bdTpZ46FsSMOpgYpI6LXWfI7dNBFZ
uyVKClGTtcbJmONo8NEPR+ELgNltgLacvMHzZECavsqge42RDmfcBCFOr3AdiLSR
85DANZxZ5sRCMaZHEz+5DhL/x+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Igz+c3YhbU1eu2y3yBCOkMbQ05/xA4xSdQfUPdTVZQKBgQls0hLLjqJf7ag7
rbw2gP9e72jwXdO+FyChohY5TNv3081azT/pHdNaAQset1dCBtibhtwjO6HMwXEB
FB1gREpjQSw0rs9n/MLm0ASWVftfn84QX0Uanpz7/Ma18x7TBUX21kZusWCtVjUG
XY1SLPWC2KRvi85oYPvpNFI1NKUD1g==
-----END PRIVATE KEY-----";

/// <summary>
/// Certificate raw text.
/// </summary>
public const string PublicCertificate = @"-----BEGIN CERTIFICATE-----
MIIDzzCCAragAwIBAgIBADANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UEBhMCdXMx
ETAPBgNVBAgMCE5ldyBZb3JrMQ8wDQYDVQQKDAZKaXRiaXQxIDAeBgNVBAMMF2Fz
cG5ldHNhbWwuaml0Yml0LmxvY2FsMRYwFAYDVQQHDA1OZXcgWW9yayBDaXR5MRMw
EQYDVQQLDApBc3BOZXRTYW1sMB4XDTIzMDgyNjE1MTkwMFoXDTMzMDgyMzE1MTkw
MFowgYAxCzAJBgNVBAYTAnVzMREwDwYDVQQIDAhOZXcgWW9yazEPMA0GA1UECgwG
Sml0Yml0MSAwHgYDVQQDDBdhc3BuZXRzYW1sLmppdGJpdC5sb2NhbDEWMBQGA1UE
BwwNTmV3IFlvcmsgQ2l0eTETMBEGA1UECwwKQXNwTmV0U2FtbDCCASMwDQYJKoZI
hvcNAQEBBQADggEQADCCAQsCggECANv55Utff+lxhteC6y1bVhJJMh7vfsq4mov0
LGJuMvaNoRe+gzTOWXBh3K9Z2uegny0AGgoc+1IZEm/p8fv5yrfXMuPnRHpbPi7N
1mvfuikF2Tl5rRgd5o46Y27WKR8U0xpPRVe6P2Sqh3xX83RC/vt4NqLE6K9Xaedc
bGuBiH+b10quvlt1OlnjoWxIw6mBikjotdZ8jt00EVm7JUoKUZO1xsmY42jw0Q9H
4QuA2W2Atpy8wfNkQJq+yqB7jZEOZ9wEIU6vcB2ItJHzkMA1nFnmxEIxpkcTP7kO
Ev/H4wblRUX2HsOW+AkzPViC93UQC9uFHSJ9BAPJBbpcm0fdsWKzAgMBAAGjUDBO
MB0GA1UdDgQWBBSyDqBxnYWoWDEO/KM7qBRzpmrMfTAfBgNVHSMEGDAWgBSyDqBx
nYWoWDEO/KM7qBRzpmrMfTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4IB
AgBXHSnFy9CiwEWMf1/AECqJxUqYZAl/e4Hso5gN8z/VVFlElHh5/gvDRVZMiIel
GBTfihwE7C2ftbD5u9RDAsaktkEseL/QDDYqJScwtosYxMgZLaINdXilkyi9xc72
6akVo+xx/qCnZYAf4Cs8k+WZXvn6rjUmjgrzFHCAlPvXp2PCyCHS2PFcAmkKHr2V
EcEnHvJi/ujia9gMF8dlbOw+Brbl8KcQ8IVinHB3/C8Op4lynoMFdrv6boDFHEyh
p3Jm5xUMH1/ow3qJ+Ffv2chCD0R6RPUXbhNUixZPuPRECbW0TDp+GgDtKCNMuB0m
ugfn/Qef81oPEImyoMWd0ReQvA==
-----END CERTIFICATE-----";

/// <summary>
/// CSR raw text.
/// </summary>
public const string CertificateSigningRequest = @"-----BEGIN CERTIFICATE REQUEST-----
MIICyDCCAa8CAQAwgYAxCzAJBgNVBAYTAnVzMREwDwYDVQQIDAhOZXcgWW9yazEP
MA0GA1UECgwGSml0Yml0MSAwHgYDVQQDDBdhc3BuZXRzYW1sLmppdGJpdC5sb2Nh
bDEWMBQGA1UEBwwNTmV3IFlvcmsgQ2l0eTETMBEGA1UECwwKQXNwTmV0U2FtbDCC
ASMwDQYJKoZIhvcNAQEBBQADggEQADCCAQsCggECANv55Utff+lxhteC6y1bVhJJ
Mh7vfsq4mov0LGJuMvaNoRe+gzTOWXBh3K9Z2uegny0AGgoc+1IZEm/p8fv5yrfX
MuPnRHpbPi7N1mvfuikF2Tl5rRgd5o46Y27WKR8U0xpPRVe6P2Sqh3xX83RC/vt4
NqLE6K9XaedcbGuBiH+b10quvlt1OlnjoWxIw6mBikjotdZ8jt00EVm7JUoKUZO1
xsmY42jw0Q9H4QuA2W2Atpy8wfNkQJq+yqB7jZEOZ9wEIU6vcB2ItJHzkMA1nFnm
xEIxpkcTP7kOEv/H4wblRUX2HsOW+AkzPViC93UQC9uFHSJ9BAPJBbpcm0fdsWKz
AgMBAAGgADANBgkqhkiG9w0BAQ0FAAOCAQIAcs7QprOVI+4Q8c6A/xlEqHzYJte3
mdkCDmZsuO8FH6oRY0fybPv4NAziTGnWg7s7sabAMvnE79zOhPT6/LqSxvofMj0t
lbO62COVMT1NUGYCnb7346oouvscIZusey8olEIf8EwiQTmCm7ait7MrnA9Mi0Tc
VExbYdfBZZcOFMZJmG4bQz+G66SEdBemlyGrdMxDR9+pwgBOG49wDOfyIk6rvkG3
A3ZafNtw5AXMLEWegWs6AEH1tkRMrJgIX9jQwP7mu3RocRzkrbSz2juzlLgyLDPn
t9RbkNHiT5rwOlSe3b86oonejHDEj4RDVNr89/6LJ3KxAsL5bUGCJaQbhWU=
-----END CERTIFICATE REQUEST-----";

/// <summary>
/// Test certificate instance.
/// </summary>
public static X509Certificate2 Certificate => new Lazy<X509Certificate2>(() => X509Certificate2.CreateFromPem(PublicCertificate, PrivateKey)).Value;
}
}
Loading

0 comments on commit 25cf07b

Please sign in to comment.