示例#1
0
        public IJwsTool GenerateSigner()
        {
            if (KeyType.StartsWith("ES"))
            {
                var tool = new ACMESharp.Crypto.JOSE.Impl.ESJwsTool
                {
                    HashSize = int.Parse(KeyType.Substring(2))
                };
                tool.Init();
                tool.Import(KeyExport);
                return(tool);
            }

            if (KeyType.StartsWith("RS"))
            {
                var tool = new ACMESharp.Crypto.JOSE.Impl.RSJwsTool
                {
                    KeySize = int.Parse(KeyType.Substring(2))
                };
                tool.Init();
                tool.Import(KeyExport);
                return(tool);
            }

            throw new Exception($"Unknown or unsupported KeyType [{KeyType}]");
        }
示例#2
0
        async Task GetTermsOfService()
        {
            var signer  = new ACMESharp.Crypto.JOSE.Impl.RSJwsTool();
            var acmeUrl = new Uri(Program.LetsEncryptV2StagingEndpoint);

            _http             = new HttpClient();
            _http.BaseAddress = acmeUrl;

            WriteLine("getting from: " + acmeUrl);

            using (var acme = new AcmeProtocolClient(_http, signer: signer))
            {
                acme.BeforeAcmeSign = (s, o) => WriteLine($"BEFORE({s}, {JsonConvert.SerializeObject(o)})");

                var dir = await acme.GetDirectoryAsync();

                WriteLine("Got Directory: " + dir);
                WriteLine("TOS: " + dir.Meta?.TermsOfService);
            }
        }