private void SaveCRTPrivateKey(CSR csr) { using (TextWriter writer = new StreamWriter(@"c:\temp\crt.key")) { CertificateUtility.ExportRSAPrivateKey(csr.RSAParameters, writer); } }
private void SaveAccountAndChallengeData(AcmeAccount account, IEnumerable <IAcmeChallengeContent> challenges, AcmeCertificateFulfillmentPromise promise) { string baseFolder = @"c:\temp"; var serializedAccount = JsonConvert.SerializeObject(account, Formatting.None); serializedAccount = Convert.ToBase64String(Encoding.UTF8.GetBytes(serializedAccount)); using (FileStream fs = new FileStream(Path.Combine(baseFolder, "myaccount.acc"), FileMode.Create)) { byte[] buffer = Encoding.UTF8.GetBytes(serializedAccount); fs.Write(buffer, 0, buffer.Length); } var sChallenges = JsonConvert.SerializeObject(challenges, Formatting.None); sChallenges = Convert.ToBase64String(Encoding.UTF8.GetBytes(sChallenges)); using (FileStream fs = new FileStream(Path.Combine(baseFolder, "challenges.dat"), FileMode.Create)) { byte[] buffer = Encoding.UTF8.GetBytes(sChallenges); fs.Write(buffer, 0, buffer.Length); } var sCertificatePromise = JsonConvert.SerializeObject(promise); sCertificatePromise = Convert.ToBase64String(Encoding.UTF8.GetBytes(sCertificatePromise)); using (FileStream fs = new FileStream(Path.Combine(baseFolder, "challengepromise.dat"), FileMode.Create)) { byte[] buffer = Encoding.UTF8.GetBytes(sCertificatePromise); fs.Write(buffer, 0, buffer.Length); } foreach (var challenge in challenges) { challenge.SaveToFile(Path.Combine(baseFolder, challenge.Token)); } //Create Account Private Key using (TextWriter writer = new StreamWriter(Path.Combine(baseFolder, "account.key"))) { CertificateUtility.ExportRSAPrivateKey(account.SecurityInfo, writer); } }