/// <summary> /// Creates a signature from the enqueued parts. /// </summary> /// <param name="configuration">The configuration of properties used to create the signature. /// See the documented of <see cref="SignConfigurationSet"/> for more information.</param> public OpcSignature Sign(SignConfigurationSet configuration) { var fileName = configuration.PublicCertificate.GetCertHashString() + ".psdsxs"; var(allParts, signatureFile) = SignCore(fileName); var signingContext = new SigningContext(configuration); var fileManifest = OpcSignatureManifest.Build(signingContext, allParts); var builder = new XmlSignatureBuilder(signingContext); builder.SetFileManifest(fileManifest); var result = builder.Build(); PublishSignature(result, signatureFile); _package.Flush(); return(new OpcSignature(signatureFile)); }
/// <summary> /// Creates a signature from the enqueued parts. /// </summary> /// <param name="configuration">The configuration of properties used to create the signature. /// See the documented of <see cref="CertificateSignConfigurationSet"/> for more information.</param> public async Task <OpcSignature> SignAsync(CertificateSignConfigurationSet configuration) { var fileName = configuration.SigningCertificate.GetCertHashString() + ".psdsxs"; var(allParts, signatureFile) = SignCore(fileName); using (var signingContext = new CertificateSigningContext(configuration.SigningCertificate, configuration.PkcsDigestAlgorithm, configuration.FileDigestAlgorithm)) { var fileManifest = OpcSignatureManifest.Build(signingContext, allParts); var builder = new XmlSignatureBuilder(signingContext); builder.SetFileManifest(fileManifest); var result = await builder.BuildAsync(); PublishSignature(result, signatureFile); } _package.Flush(); return(new OpcSignature(signatureFile)); }
/// <summary> /// Creates a signature from the enqueued parts. /// </summary> /// <param name="configuration">The configuration of properties used to create the signature. /// See the documented of <see cref="AzureKeyVaultSignConfigurationSet"/> for more information.</param> public async Task <OpcSignature> SignAsync(AzureKeyVaultSignConfigurationSet configuration) { using (var azureConfiguration = await KeyVaultConfigurationDiscoverer.Materialize(configuration)) { var fileName = azureConfiguration.PublicCertificate.GetCertHashString() + ".psdsxs"; var(allParts, signatureFile) = SignCore(fileName); using (var signingContext = new KeyVaultSigningContext(azureConfiguration)) { var fileManifest = OpcSignatureManifest.Build(signingContext, allParts); var builder = new XmlSignatureBuilder(signingContext); builder.SetFileManifest(fileManifest); var result = await builder.BuildAsync(); PublishSignature(result, signatureFile); } _package.Flush(); return(new OpcSignature(signatureFile)); } }
private async Task <OpcSignature> SignAsyncImpl <TConfig, TContext>(TConfig configuration) where TConfig : ISignConfigurationSet where TContext : ISigningContext { var fileName = configuration.SigningCertificate.GetCertHashString() + ".psdsxs"; var(allParts, signatureFile) = SignCore(fileName); var signingContext = (TContext)Activator.CreateInstance(typeof(TContext), configuration); using (signingContext) { var fileManifest = OpcSignatureManifest.Build(signingContext, allParts); var builder = new XmlSignatureBuilder(signingContext); builder.SetFileManifest(fileManifest); var result = await builder.BuildAsync(); PublishSignature(result, signatureFile); } _package.Flush(); return(new OpcSignature(signatureFile)); }