コード例 #1
0
            public async Task CanChangeAccountKey()
            {
                var dirUri = await GetAcmeUriV2();

                var ctx     = new AcmeContext(dirUri, http: GetAcmeHttpClient(dirUri));
                var account = await ctx.NewAccount(
                    new[] { $"mailto:certes-{DateTime.UtcNow.Ticks}@example.com" }, true);

                var location = await ctx.Account().Location();

                var newKey = KeyFactory.NewKey(KeyAlgorithm.ES256);
                await ctx.ChangeKey(newKey);

                var ctxWithNewKey      = new AcmeContext(dirUri, newKey, http: GetAcmeHttpClient(dirUri));
                var locationWithNewKey = await ctxWithNewKey.Account().Location();

                Assert.Equal(location, locationWithNewKey);
            }
コード例 #2
0
ファイル: IntegrationHelper.cs プロジェクト: wiggisser/certes
        public static async Task <Uri> GetAcmeUriV2()
        {
            if (stagingServerV2 != null)
            {
                return(stagingServerV2);
            }

            var servers = new[] {
                //new Uri("https://lo0.in:4431/directory"),
                new Uri("https://boulder-certes-ci.dymetis.com:4431/directory"),
                //WellKnownServers.LetsEncryptStagingV2,
            };

            var exceptions = new List <Exception>();

            foreach (var uri in servers)
            {
                try
                {
                    await http.Value.GetStringAsync(uri);

                    foreach (var algo in new[] { KeyAlgorithm.ES256, KeyAlgorithm.ES384, KeyAlgorithm.RS256 })
                    {
                        try
                        {
                            var ctx = new AcmeContext(uri, Helper.GetKeyV2(algo), GetAcmeHttpClient(uri));
                            await ctx.NewAccount(new[] { "mailto:[email protected]" }, true);
                        }
                        catch
                        {
                        }
                    }

                    return(stagingServerV2 = uri);
                }
                catch (Exception ex)
                {
                    exceptions.Add(ex);
                }
            }

            throw new AggregateException("No staging server available.", exceptions);
        }
コード例 #3
0
            public async Task CanRunAccountFlows()
            {
                var dirUri = await GetAcmeUriV2();

                var ctx        = new AcmeContext(dirUri, http: GetAcmeHttpClient(dirUri));
                var accountCtx = await ctx.NewAccount(
                    new[] { $"mailto:certes-{DateTime.UtcNow.Ticks}@example.com" }, true);

                var account = await accountCtx.Resource();

                var location = accountCtx.Location;

                Assert.NotNull(account);
                Assert.Equal(AccountStatus.Valid, account.Status);

                await accountCtx.Update(agreeTermsOfService : true);

                await accountCtx.Update(contact : new[] { $"mailto:certes-{DateTime.UtcNow.Ticks}@example.com" });

                account = await accountCtx.Deactivate();

                Assert.NotNull(account);
                Assert.Equal(AccountStatus.Deactivated, account.Status);
            }