private static void EncryptResponse(StringBuilder buffer, Success successResponse) { Console.WriteLine("======================================================================="); Console.WriteLine($"Responding with:\n{JsonConvert.SerializeObject(successResponse)}"); var encrypted = JweMessage.CreateFrom( successResponse, ClientEncryptionCert, new List <X509Certificate2> { IssuerSigningCert }); Console.WriteLine("======================================================================="); Console.WriteLine($"Responding with encrypted Payload:\n{encrypted}"); buffer.AppendLine(encrypted); }
public void RoundTripEncryptAndDecryptMessageShouldBeLossless() { var jweMessage = JweMessage.CreateFrom <GetCardInfoRequest>( CardInfoMessage, IssuerEncryptionCert.GetP12Cert(), new List <X509Certificate2> { IssuerEncryptionCert.GetP12Cert() }); jweMessage.Should().NotBeNull(); var decryptedMessage = JweMessage.FromEncryptedString <GetCardInfoRequest>( jweMessage, new List <X509Certificate2> { IssuerEncryptionCert.GetP12Cert() }, new DevJweCryptoPolicy()); decryptedMessage.Should().BeEquivalentTo(CardInfoMessage); }