@@ -11,9 +11,9 @@ import (
11
11
"github.com/notaryproject/notation-core-go/signature"
12
12
"github.com/notaryproject/notation-go"
13
13
"github.com/notaryproject/notation-go/dir"
14
- "github.com/notaryproject/notation-go/internal/pkix "
15
- "github.com/notaryproject/notation-go/internal/slice "
16
- trustpolicyInternal "github.com/notaryproject/notation-go/internal/trustpolicy "
14
+ "github.com/notaryproject/notation-go/internal/slices "
15
+ "github.com/notaryproject/notation-go/plugin "
16
+ "github.com/notaryproject/notation-go/plugin/proto "
17
17
"github.com/notaryproject/notation-go/verifier/trustpolicy"
18
18
"github.com/notaryproject/notation-go/verifier/truststore"
19
19
)
@@ -82,51 +82,11 @@ func isCriticalFailure(result *notation.ValidationResult) bool {
82
82
return result .Action == trustpolicy .ActionEnforce && result .Error != nil
83
83
}
84
84
85
- func verifyX509TrustedIdentitiesCore (certs []* x509.Certificate , trustPolicy * trustpolicy.TrustPolicy ) error {
86
- if slice .Contains (trustPolicy .TrustedIdentities , trustpolicyInternal .Wildcard ) {
87
- return nil
88
- }
89
-
90
- var trustedX509Identities []map [string ]string
91
- for _ , identity := range trustPolicy .TrustedIdentities {
92
- i := strings .Index (identity , ":" )
93
-
94
- identityPrefix := identity [:i ]
95
- identityValue := identity [i + 1 :]
96
-
97
- if identityPrefix == trustpolicyInternal .X509Subject {
98
- parsedSubject , err := pkix .ParseDistinguishedName (identityValue )
99
- if err != nil {
100
- return err
101
- }
102
- trustedX509Identities = append (trustedX509Identities , parsedSubject )
103
- }
104
- }
105
-
106
- if len (trustedX509Identities ) == 0 {
107
- return fmt .Errorf ("no x509 trusted identities are configured in the trust policy %q" , trustPolicy .Name )
108
- }
109
-
110
- leafCert := certs [0 ] // trusted identities only supported on the leaf cert
111
-
112
- leafCertDN , err := pkix .ParseDistinguishedName (leafCert .Subject .String ()) // parse the certificate subject following rfc 4514 DN syntax
113
- if err != nil {
114
- return fmt .Errorf ("error while parsing the certificate subject from the digital signature. error : %q" , err )
115
- }
116
- for _ , trustedX509Identity := range trustedX509Identities {
117
- if pkix .IsSubsetDN (trustedX509Identity , leafCertDN ) {
118
- return nil
119
- }
120
- }
121
-
122
- return fmt .Errorf ("signing certificate from the digital signature does not match the X.509 trusted identities %q defined in the trust policy %q" , trustedX509Identities , trustPolicy .Name )
123
- }
124
-
125
85
func getNonPluginExtendedCriticalAttributes (signerInfo * signature.SignerInfo ) []signature.Attribute {
126
86
var criticalExtendedAttrs []signature.Attribute
127
87
for _ , attr := range signerInfo .SignedAttributes .ExtendedAttributes {
128
88
attrStrKey , ok := attr .Key .(string )
129
- if ok && ! slice .Contains (VerificationPluginHeaders , attrStrKey ) { // filter the plugin extended attributes
89
+ if ok && ! slices .Contains (VerificationPluginHeaders , attrStrKey ) { // filter the plugin extended attributes
130
90
// TODO support other attribute types (COSE attribute keys can be numbers)
131
91
criticalExtendedAttrs = append (criticalExtendedAttrs , attr )
132
92
}
@@ -181,3 +141,22 @@ func getVerificationPluginMinVersion(signerInfo *signature.SignerInfo) (string,
181
141
}
182
142
return version , nil
183
143
}
144
+
145
+ // getPluginMetadata gets metadata of the plugin
146
+ func getPluginMetadata (ctx context.Context , installedPlugin plugin.Plugin , pluginConfig map [string ]string ) (* proto.GetMetadataResponse , error ) {
147
+ req := & proto.GetMetadataRequest {
148
+ PluginConfig : pluginConfig ,
149
+ }
150
+ metadata , err := installedPlugin .GetMetadata (ctx , req )
151
+ if err != nil {
152
+ return nil , err
153
+ }
154
+ if ! metadata .SupportsContract (proto .ContractVersion ) {
155
+ return nil , fmt .Errorf (
156
+ "contract version %q is not in the list of the plugin supported versions %v" ,
157
+ proto .ContractVersion , metadata .SupportedContractVersions ,
158
+ )
159
+ }
160
+
161
+ return metadata , nil
162
+ }
0 commit comments