@@ -22,30 +22,32 @@ public class SignatureFormatValidator : ISignatureFormatValidator
2222 allowMultipleTimestamps : true ,
2323 allowNoTimestamp : true ,
2424 allowUnknownRevocation : true ,
25+ reportUnknownRevocation : false ,
2526 allowNoRepositoryCertificateList : true ,
2627 allowNoClientCertificateList : true ,
27- alwaysVerifyCountersignature : false ,
28+ verificationTarget : VerificationTarget . All ,
29+ signaturePlacement : SignaturePlacement . PrimarySignature ,
30+ repositoryCountersignatureVerificationBehavior : SignatureVerificationBehavior . Never ,
2831 repoAllowListEntries : null ,
2932 clientAllowListEntries : null ) ;
3033
31- private static readonly IEnumerable < ISignatureVerificationProvider > _minimalProviders = new [ ]
34+ private static readonly PackageSignatureVerifier _minimalVerifier = new PackageSignatureVerifier ( new [ ]
3235 {
3336 new MinimalSignatureVerificationProvider ( ) ,
34- } ;
37+ } ) ;
3538
36- private static readonly IEnumerable < ISignatureVerificationProvider > _fullProviders = new ISignatureVerificationProvider [ ]
39+ private static readonly PackageSignatureVerifier _fullVerifier = new PackageSignatureVerifier ( new ISignatureVerificationProvider [ ]
3740 {
3841 new IntegrityVerificationProvider ( ) ,
3942 new SignatureTrustAndValidityVerificationProvider ( ) ,
4043 new AllowListVerificationProvider ( ) ,
41- } ;
44+ } ) ;
4245
4346 private readonly IOptionsSnapshot < ProcessSignatureConfiguration > _config ;
4447 private readonly SignedPackageVerifierSettings _authorSignatureSettings ;
48+ private readonly SignedPackageVerifierSettings _repositorySignatureSettings ;
4549 private readonly SignedPackageVerifierSettings _authorOrRepositorySignatureSettings ;
4650
47- private readonly RepositorySignatureVerifier _repositorySignatureVerifier ;
48-
4951 public SignatureFormatValidator ( IOptionsSnapshot < ProcessSignatureConfiguration > config )
5052 {
5153 _config = config ?? throw new ArgumentNullException ( nameof ( config ) ) ;
@@ -58,11 +60,14 @@ public SignatureFormatValidator(IOptionsSnapshot<ProcessSignatureConfiguration>
5860 allowMultipleTimestamps : false ,
5961 allowNoTimestamp : false ,
6062 allowUnknownRevocation : true ,
61- allowNoClientCertificateList : true ,
62- alwaysVerifyCountersignature : true ,
63- clientAllowListEntries : null ,
63+ reportUnknownRevocation : true ,
6464 allowNoRepositoryCertificateList : true ,
65- repoAllowListEntries : null ) ;
65+ allowNoClientCertificateList : true ,
66+ verificationTarget : VerificationTarget . Author ,
67+ signaturePlacement : SignaturePlacement . PrimarySignature ,
68+ repositoryCountersignatureVerificationBehavior : SignatureVerificationBehavior . Never ,
69+ repoAllowListEntries : null ,
70+ clientAllowListEntries : null ) ;
6671
6772 var repoAllowListEntries = _config
6873 . Value
@@ -76,64 +81,81 @@ public SignatureFormatValidator(IOptionsSnapshot<ProcessSignatureConfiguration>
7681
7782 repoAllowListEntries = repoAllowListEntries ?? new List < CertificateHashAllowListEntry > ( ) ;
7883
79- _authorOrRepositorySignatureSettings = new SignedPackageVerifierSettings (
84+ _repositorySignatureSettings = new SignedPackageVerifierSettings (
8085 allowUnsigned : _authorSignatureSettings . AllowUnsigned ,
8186 allowIllegal : _authorSignatureSettings . AllowIllegal ,
8287 allowUntrusted : _authorSignatureSettings . AllowUntrusted ,
8388 allowIgnoreTimestamp : _authorSignatureSettings . AllowIgnoreTimestamp ,
8489 allowMultipleTimestamps : _authorSignatureSettings . AllowMultipleTimestamps ,
8590 allowNoTimestamp : _authorSignatureSettings . AllowNoTimestamp ,
8691 allowUnknownRevocation : _authorSignatureSettings . AllowUnknownRevocation ,
87- allowNoClientCertificateList : _authorSignatureSettings . AllowNoClientCertificateList ,
88- alwaysVerifyCountersignature : _authorSignatureSettings . AlwaysVerifyCountersignature ,
89- clientAllowListEntries : _authorSignatureSettings . ClientCertificateList ,
92+ reportUnknownRevocation : _authorSignatureSettings . ReportUnknownRevocation ,
9093 allowNoRepositoryCertificateList : false ,
91- repoAllowListEntries : repoAllowListEntries ) ;
94+ allowNoClientCertificateList : _authorSignatureSettings . AllowNoClientCertificateList ,
95+ verificationTarget : VerificationTarget . Repository ,
96+ signaturePlacement : SignaturePlacement . Any ,
97+ repositoryCountersignatureVerificationBehavior : SignatureVerificationBehavior . IfExists ,
98+ repoAllowListEntries : repoAllowListEntries ,
99+ clientAllowListEntries : _authorSignatureSettings . ClientCertificateList ) ;
92100
93- _repositorySignatureVerifier = new RepositorySignatureVerifier ( ) ;
101+ _authorOrRepositorySignatureSettings = new SignedPackageVerifierSettings (
102+ allowUnsigned : _authorSignatureSettings . AllowUnsigned ,
103+ allowIllegal : _authorSignatureSettings . AllowIllegal ,
104+ allowUntrusted : _authorSignatureSettings . AllowUntrusted ,
105+ allowIgnoreTimestamp : _authorSignatureSettings . AllowIgnoreTimestamp ,
106+ allowMultipleTimestamps : _authorSignatureSettings . AllowMultipleTimestamps ,
107+ allowNoTimestamp : _authorSignatureSettings . AllowNoTimestamp ,
108+ allowUnknownRevocation : _authorSignatureSettings . AllowUnknownRevocation ,
109+ reportUnknownRevocation : _authorSignatureSettings . ReportUnknownRevocation ,
110+ allowNoRepositoryCertificateList : false ,
111+ allowNoClientCertificateList : _authorSignatureSettings . AllowNoClientCertificateList ,
112+ verificationTarget : VerificationTarget . All ,
113+ signaturePlacement : SignaturePlacement . Any ,
114+ repositoryCountersignatureVerificationBehavior : SignatureVerificationBehavior . IfExists ,
115+ repoAllowListEntries : repoAllowListEntries ,
116+ clientAllowListEntries : _authorSignatureSettings . ClientCertificateList ) ;
94117 }
95118
96119 public async Task < VerifySignaturesResult > ValidateMinimalAsync (
97120 ISignedPackageReader package ,
98121 CancellationToken token )
99122 {
100- return await VerifyAsync (
123+ return await _minimalVerifier . VerifySignaturesAsync (
101124 package ,
102- _minimalProviders ,
103125 _minimalSettings ,
104126 token ) ;
105127 }
106128
107- public async Task < VerifySignaturesResult > ValidateFullAsync (
129+ public async Task < VerifySignaturesResult > ValidateAuthorSignatureAsync (
108130 ISignedPackageReader package ,
109- bool hasRepositorySignature ,
110131 CancellationToken token )
111132 {
112- var settings = hasRepositorySignature ? _authorOrRepositorySignatureSettings : _authorSignatureSettings ;
113-
114- return await VerifyAsync (
133+ return await _fullVerifier . VerifySignaturesAsync (
115134 package ,
116- _fullProviders ,
117- settings ,
135+ _authorSignatureSettings ,
118136 token ) ;
119137 }
120138
121- public async Task < SignatureVerificationStatus > VerifyRepositorySignatureAsync (
139+ public async Task < VerifySignaturesResult > ValidateRepositorySignatureAsync (
122140 ISignedPackageReader package ,
123141 CancellationToken token )
124142 {
125- return await _repositorySignatureVerifier . VerifyAsync ( package , token ) ;
143+ return await _fullVerifier . VerifySignaturesAsync (
144+ package ,
145+ _repositorySignatureSettings ,
146+ token ) ;
126147 }
127148
128- private static async Task < VerifySignaturesResult > VerifyAsync (
149+ public async Task < VerifySignaturesResult > ValidateAllSignaturesAsync (
129150 ISignedPackageReader package ,
130- IEnumerable < ISignatureVerificationProvider > verificationProviders ,
131- SignedPackageVerifierSettings settings ,
151+ bool hasRepositorySignature ,
132152 CancellationToken token )
133153 {
134- var verifier = new PackageSignatureVerifier ( verificationProviders ) ;
154+ // TODO - Use only the "authorOrRepositorySignatureSettings" once this issue is fixed:
155+ // https://github.com/NuGet/Home/issues/7042
156+ var settings = hasRepositorySignature ? _authorOrRepositorySignatureSettings : _authorSignatureSettings ;
135157
136- return await verifier . VerifySignaturesAsync (
158+ return await _fullVerifier . VerifySignaturesAsync (
137159 package ,
138160 settings ,
139161 token ) ;
0 commit comments