mirror of
https://github.com/AlexMacocian/MTSC.git
synced 2026-07-15 14:59:33 +00:00
0fe9f9957c
* Setup OAuth2 support * Setup tests project * Setup OAuth2 unit tests in CI pipeline * Setup authorizeattribute tests * Test * Setup tests for AuthorizeAttribute * Setup OAuth2 support Unit Tests coverage * Add OAuth2 project to release
30 lines
927 B
C#
30 lines
927 B
C#
using System;
|
|
using System.Security.Cryptography;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
namespace MTSC.OAuth2.Tests;
|
|
|
|
public static class CertificateUtilities
|
|
{
|
|
public static X509Certificate2 CreateNewSelfSignedCertificate()
|
|
{
|
|
using var parent = RSA.Create(4096);
|
|
using var rsa = RSA.Create(2048);
|
|
var parentReq = new CertificateRequest(
|
|
"CN=Experimental Issuing Authority",
|
|
parent,
|
|
HashAlgorithmName.SHA256,
|
|
RSASignaturePadding.Pkcs1);
|
|
|
|
parentReq.CertificateExtensions.Add(
|
|
new X509BasicConstraintsExtension(true, false, 0, true));
|
|
|
|
parentReq.CertificateExtensions.Add(
|
|
new X509SubjectKeyIdentifierExtension(parentReq.PublicKey, false));
|
|
|
|
return parentReq.CreateSelfSigned(
|
|
DateTimeOffset.UtcNow.AddDays(-45),
|
|
DateTimeOffset.UtcNow.AddDays(365));
|
|
}
|
|
}
|