Skip to content

Commit 00e29a4

Browse files
committed
Use cer format for certificate signing
1 parent 677978b commit 00e29a4

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/EasySign/Bundle.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,24 +444,20 @@ public void Sign(X509Certificate2 certificate, RSA privateKey)
444444
Logger.LogInformation("Signing bundle with certificate: {name}", certificate.Subject);
445445

446446
Logger.LogDebug("Exporting certificate");
447-
string cert = Convert.ToBase64String(certificate.Export(X509ContentType.Cert));
447+
byte[] certData = certificate.Export(X509ContentType.Cert);
448448
string name = certificate.GetCertHashString();
449449

450-
StringBuilder pemBuilder = new StringBuilder();
451-
pemBuilder.AppendLine("-----BEGIN CERTIFICATE-----");
452-
pemBuilder.AppendLine(cert);
453-
pemBuilder.AppendLine("-----END CERTIFICATE-----");
454-
string pemContents = pemBuilder.ToString();
455-
456450
Logger.LogDebug("Signing manifest");
457451
byte[] manifestData = GetManifestData();
458452
byte[] signature = privateKey.SignData(manifestData, HashAlgorithmName.SHA512, RSASignaturePadding.Pkcs1);
459453

460-
Logger.LogDebug("Pending file: {name} for embedding in the bundle", name);
461-
_pendingForAdd[name] = Encoding.UTF8.GetBytes(pemContents);
454+
Logger.LogDebug("Pending file: {name} for adding to the bundle", name);
455+
_pendingForAdd[name] = certData;
462456

463457
Logger.LogDebug("Adding signature for certificate: {name} to signatures", name);
464458
Signatures.Entries[name] = signature;
459+
460+
Logger.LogInformation("Bundle signed with certificate: {name}", certificate.Subject);
465461
}
466462

467463
/// <summary>

0 commit comments

Comments
 (0)