-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPZVerify.cs
More file actions
41 lines (35 loc) · 1.17 KB
/
PZVerify.cs
File metadata and controls
41 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using OldMusicBox.ePUAP.Client.Model.Common;
using OldMusicBox.ePUAP.Client;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using OldMusicBox.ePUAP.Client.Model.VerifySignedDocument;
using Newtonsoft.Json;
namespace PZBridge
{
internal class PZVerify
{
public static void Execute(X509Certificate2 cert, string[] args)
{
if (args.Length < 1)
{
Program.SendFault("verify: not enough arguments\nsyntax: verify <env>\nstdin: <document> \\n EOF");
return;
}
if (args[0] == "stub") {
Program.SendFault("verify: this operation isn't supported in stub mode");
return;
}
TpSigning5Client client = new(args[0] == "prod" ? TpSigning5Client.PRODUCTION_URI : TpSigning5Client.INTEGRATION_URI, cert);
string document = Program.GetDocumentFromStandardInput();
byte[] documentBytes = Encoding.UTF8.GetBytes(document);
FaultModel faultModel;
VerifySignedDocument5Response response = client.VerifySignedDocument(documentBytes, out faultModel);
if(faultModel != null)
{
Program.SendFault(faultModel);
return;
}
Console.Write("{\"ok\": true, \"data\": " + JsonConvert.SerializeObject(response) + "}");
}
}
}