Exemplo n.º 1
0
        public static AcmeClient GetClient(VaultInfo config, RegistrationInfo reg)
        {
            var c = GetClient(config);

            c.Signer = GetSigner(reg.SignerProvider);
            c.Signer.Init();
            c.Registration = reg.Registration;

            if (reg.SignerState != null)
            {
                using (var s = new MemoryStream(Convert.FromBase64String(
                        reg.SignerState)))
                {
                    c.Signer.Load(s);
                }
            }
            else
            {
                using (var s = new MemoryStream())
                {
                    c.Signer.Save(s);
                    reg.SignerState = Convert.ToBase64String(s.ToArray());
                }
            }

            return c;
        }
Exemplo n.º 2
0
        public static void Init(VaultInfo config, AcmeClient client)
        {
            client.Init();

            if (config.GetInitialDirectory)
                client.GetDirectory(config.UseRelativeInitialDirectory);
        }
Exemplo n.º 3
0
        public static AcmeClient GetClient(VaultInfo Config)
        {
            var p = Config.Proxy;
            var _Client = new AcmeClient();

            _Client.RootUrl = new Uri(Config.BaseUri);
            _Client.Directory = Config.ServerDirectory;

            if (Config.Proxy != null)
                _Client.Proxy = Config.Proxy.GetWebProxy();

            return _Client;
        }
Exemplo n.º 4
0
        protected override void ProcessRecord()
        {
            var baseUri = BaseUri;
            if (string.IsNullOrEmpty(baseUri))
            {
                if (!string.IsNullOrEmpty(BaseService)
                        && WELL_KNOWN_BASE_SERVICES.ContainsKey(BaseService))
                {
                    baseUri = WELL_KNOWN_BASE_SERVICES[BaseService];
                    WriteVerbose($"Resolved Base URI from Base Service [{baseUri}]");
                }
                else
                    throw new PSInvalidOperationException("either a base service or URI is required");
            }

            using (var vlt = Util.VaultHelper.GetVault(VaultProfile))
            {
                WriteVerbose("Initializing Storage Backend");
                vlt.InitStorage(Force);
                var v = new VaultInfo
                {
                    Id = EntityHelper.NewId(),
                    Alias = Alias,
                    Label = Label,
                    Memo = Memo,
                    BaseService = BaseService,
                    BaseUri = baseUri,
                    ServerDirectory = new AcmeServerDirectory()
                };

                vlt.SaveVault(v);
            }
        }