Skip to content

Commit 0c3964f

Browse files
committed
Store certificates in signatures file
1 parent e7c8360 commit 0c3964f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/EasySign/Bundle.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -447,18 +447,13 @@ public void Sign(X509Certificate2 certificate, RSA privateKey)
447447
byte[] certData = certificate.Export(X509ContentType.Cert);
448448
string name = certificate.GetCertHashString();
449449

450-
Logger.LogDebug("Adding entry name: {name} to protected entry names", name);
451-
ProtectedEntryNames.Add(name);
452-
453450
Logger.LogDebug("Signing manifest");
454451
byte[] manifestData = GetManifestData();
455452
byte[] signature = privateKey.SignData(manifestData, HashAlgorithmName.SHA512, RSASignaturePadding.Pkcs1);
456453

457-
Logger.LogDebug("Pending file: {name} for adding to the bundle", name);
458-
_pendingForAdd[name] = certData;
459-
460454
Logger.LogDebug("Adding signature for certificate: {name} to signatures", name);
461455
Signatures.Entries[name] = signature;
456+
Signatures.Certificates[name] = certData;
462457

463458
Logger.LogInformation("Bundle signed with certificate: {name}", certificate.Subject);
464459
}
@@ -579,7 +574,7 @@ public X509Certificate2 GetCertificate(string certificateHash)
579574

580575
Logger.LogInformation("Getting certificate with hash: {hash}", certificateHash);
581576

582-
byte[] certData = GetBytes(certificateHash, ReadSource.Bundle);
577+
byte[] certData = Signatures.Certificates[certificateHash];
583578

584579
#if NET9_0_OR_GREATER
585580
X509Certificate2 certificate = X509CertificateLoader.LoadCertificate(certData);

src/EasySign/Signatures.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public class Signatures
1111
/// Gets or sets the signature entries.
1212
/// </summary>
1313
public Dictionary<string, byte[]> Entries { get; set; } = [];
14+
15+
/// <summary>
16+
/// Gets or sets the signature certificates.
17+
/// </summary>
18+
public Dictionary<string, byte[]> Certificates { get; set; } = [];
1419
}
1520

1621
[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata, WriteIndented = false, DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]

0 commit comments

Comments
 (0)