Exemplo n.º 1
0
		public static void GenerateRSA(string[] args, Action<string, string> saveAction)
		{
			//Grab the incoming args.
			//Should contain cert name as first arg
			ArgParser appArgs = new ArgParser(args);

			//This will load the cert file with the provided path.
			CertLoader loader = new CertLoader(appArgs.CertName);

			//Once we've loaded the cert we need to pull the RSA data from it.
			//We want to also load it with the private key.
			RSACryptoServiceProvider provider = new CertToRSAProviderConverter(loader.Certificate, true).Provider;
			RSAExportFormatter formatter = new RSAExportFormatter(provider);

			try
			{
				saveAction(formatter.ClientRSAXML, $"{appArgs.CertName.Replace(".pfx", "")}Client.rsa");

				saveAction(formatter.ServerRSAXML, $"{appArgs.CertName.Replace(".pfx", "")}Server.rsa");
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				Console.WriteLine(e.StackTrace);
				Console.ReadKey();
			}
		}
Exemplo n.º 2
0
        public static void GenerateRSA(string[] args, Action <string, string> saveAction)
        {
            //Grab the incoming args.
            //Should contain cert name as first arg
            ArgParser appArgs = new ArgParser(args);

            //This will load the cert file with the provided path.
            CertLoader loader = new CertLoader(appArgs.CertName);

            //Once we've loaded the cert we need to pull the RSA data from it.
            //We want to also load it with the private key.
            RSACryptoServiceProvider provider  = new CertToRSAProviderConverter(loader.Certificate, true).Provider;
            RSAExportFormatter       formatter = new RSAExportFormatter(provider);

            try
            {
                saveAction(formatter.ClientRSAXML, $"{appArgs.CertName.Replace(".pfx", "")}Client.rsa");

                saveAction(formatter.ServerRSAXML, $"{appArgs.CertName.Replace(".pfx", "")}Server.rsa");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Console.ReadKey();
            }
        }