Пример #1
0
        private X509Certificate2 CreateAndSaveSelfSignedCertificate(string filePath, string commonName = LocalHost)
        {
            const string promptMessage = "Catalyst Node needs to create an SSL certificate." +
                                         " Please enter a password to encrypt the certificate on disk:";

            using (var password = _passwordManager.RetrieveOrPromptAndAddPasswordToRegistry(_certificatePasswordIdentifier, promptMessage))
            {
                var certificate = BuildSelfSignedServerCertificate(password, commonName);
                Save(certificate, filePath, password);
                return(certificate);
            }
        }
        public IpfsAdapterTests(ITestOutputHelper output) : base(output)
        {
            _passwordManager = Substitute.For <IPasswordManager>();
            _passwordManager.RetrieveOrPromptAndAddPasswordToRegistry(PasswordRegistryTypes.IpfsPassword,
                                                                      Arg.Any <string>()).ReturnsForAnyArgs(
                TestPasswordReader.BuildSecureStringPassword("abcd"));

            _logger = Substitute.For <ILogger>();
        }
        public IpfsAdapter(IPasswordManager passwordReader,
                           IFileSystem fileSystem,
                           ILogger logger,
                           string swarmKey = "07a8e9d0c43400927ab274b7fa443596b71e609bacae47bd958e5cd9f59d6ca3",
                           IEnumerable <MultiAddress> seedServers = null)
        {
            if (seedServers == null || seedServers.Count() == 0)
            {
                seedServers = new[]
                {
                    new MultiAddress("/ip4/165.22.209.154/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZdzVq4jUMZsJKddJPrwWjkcwtf23ZcGFW2xUCmSE29ABRs"),
                    new MultiAddress("/ip4/165.22.226.50/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZe2jBdLcqbqE6qLfApXJLPr855vycKygWXnRsMVXuW8o1E"),
                    new MultiAddress("/ip4/167.71.129.154/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZe79QPeKgXsvTvVTPV732TnSya3MqQ5YUMcGHZFxW1VAEC"),
                    new MultiAddress("/ip4/167.71.79.54/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZe4BowwZZyjRazPAMd5VhWBfvM88Qcyy3viWGQ8fzEhcvc"),
                    new MultiAddress("/ip4/167.71.79.77/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZe64FqVyvgWoLYBktgShFe6oEYeDWox8o2WhA8brQu5dBA"),
                    new MultiAddress("/ip4/165.22.175.71/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZdwHHKV44GJfKE9ecyRXHcXY4yNtEExgPSvvwsDtvZspZj"),
                    new MultiAddress("/ip4/165.22.234.49/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZdxSv6GpHsHAVYb51xvH3y4xvGVztM1h1GEsUjEzqc8Wh4"),
                    new MultiAddress("/ip4/167.71.134.31/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZe4SkF2tXtZbBMUSsmbosM5SAJaU3oxUAbReFDBaKeHqR3")
                };
            }

            _logger = logger;

            // The password is used to access the private keys.
            var password = passwordReader.RetrieveOrPromptAndAddPasswordToRegistry(PasswordRegistryTypes.IpfsPassword, "Please provide your IPFS password");

            _ipfs = new IpfsEngine(password);
            _ipfs.Options.KeyChain.DefaultKeyType = Constants.KeyChainDefaultKeyType;

            // The IPFS repository is inside the catalyst home folder.
            _ipfs.Options.Repository.Folder = Path.Combine(
                fileSystem.GetCatalystDataDir().FullName,
                Constants.DfsDataSubDir);

            // The seed nodes for the catalyst network.
            _ipfs.Options.Discovery.BootstrapPeers = seedServers;

            // Do not use the public IPFS network, use a private network
            // of catalyst only nodes.
            _ipfs.Options.Swarm.PrivateNetworkKey = new PreSharedKey
            {
                Value = swarmKey.ToHexBuffer()
            };

            _logger.Information("IPFS configured.");
        }
Пример #4
0
        public IpfsAdapter(IPasswordManager passwordReader,
                           IFileSystem fileSystem,
                           ILogger logger,
                           string swarmKey = "07a8e9d0c43400927ab274b7fa443596b71e609bacae47bd958e5cd9f59d6ca3",
                           IEnumerable <MultiAddress> seedServers = null)
        {
            if (seedServers == null || seedServers.Count() == 0)
            {
                seedServers = new[]
                {
                    new MultiAddress("/ip4/46.101.132.61/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZdtAkDHgs8MDwwhtyLu8JpYitY4Nk8jmyGgQ4Gt3VKNson"),
                    new MultiAddress("/ip4/188.166.13.135/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZe2AAPTCoujCxhJHECaySDEsPrEz9W2u7uo6hAbJhYzhPg"),
                    new MultiAddress("/ip4/167.172.73.132/tcp/4001/ipfs/18n3naE9kBZoVvgYMV6saMZe1E9wXdykR6h3Q9EaQcQc6hdNAXyCTEzoGfcA2wQgCRyg")
                };
            }

            _logger = logger;

            // The password is used to access the private keys.
            var password = passwordReader.RetrieveOrPromptAndAddPasswordToRegistry(PasswordRegistryTypes.IpfsPassword, "Please provide your IPFS password");

            _ipfs = new IpfsEngine(password);
            _ipfs.Options.KeyChain.DefaultKeyType = Constants.KeyChainDefaultKeyType;

            // The IPFS repository is inside the catalyst home folder.
            _ipfs.Options.Repository.Folder = Path.Combine(
                fileSystem.GetCatalystDataDir().FullName,
                Constants.DfsDataSubDir);

            // The seed nodes for the catalyst network.
            _ipfs.Options.Discovery.BootstrapPeers = seedServers;

            // Do not use the public IPFS network, use a private network
            // of catalyst only nodes.
            _ipfs.Options.Swarm.PrivateNetworkKey = new PreSharedKey
            {
                Value = swarmKey.ToHexBuffer()
            };

            _logger.Information("IPFS configured.");
        }
Пример #5
0
 private void Create_a_certificate_file_with_password()
 {
     _fileWithPassName = "test-with-pass.pfx";
     _passwordManager.RetrieveOrPromptAndAddPasswordToRegistry(Arg.Is(PasswordRegistryTypes.CertificatePassword)).Returns(TestPasswordReader.BuildSecureStringPassword("password"));
     _createdCertificate = _certificateStore.ReadOrCreateCertificateFile(_fileWithPassName);
 }