Exemplo n.º 1
0
 public void Apply(OpenApiSchema schema, SchemaFilterContext context)
 {
     if (context.Type == typeof(Psd2CertificateRequest))
     {
         schema.Example = Psd2CertificateRequest.Example().ToOpenApiAny();
     }
 }
Exemplo n.º 2
0
        public void Generate_QWACs()
        {
            var data          = Psd2CertificateRequest.Example();
            var manager       = new CertificateManager();
            var privateKey    = default(RSA);
            var cert          = manager.CreateQWACs(data, out privateKey);
            var certBase64    = cert.ExportToPEM();
            var publicBase64  = privateKey.ToSubjectPublicKeyInfo();
            var privateBase64 = privateKey.ToRSAPrivateKey();
            var pfxBytes      = cert.Export(X509ContentType.Pfx, "111");

            File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), $"{data.AuthorizationNumber}.cer"), certBase64);
            File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), $"{data.AuthorizationNumber}.public.key"), publicBase64);
            File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), $"{data.AuthorizationNumber}.private.key"), privateBase64);
            File.WriteAllBytes(Path.Combine(Directory.GetCurrentDirectory(), $"{data.AuthorizationNumber}.pfx"), pfxBytes);
            File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), $"{data.AuthorizationNumber}.json"), JsonConvert.SerializeObject(new {
                encodedCert = certBase64,
                privateKey  = privateBase64,
                keyId       = CryptoRandom.CreateUniqueId(16),
                algorithm   = "SHA256WITHRSA"
            }));
            Assert.True(true);
        }