Skip to content

Commit

Permalink
Merge branch 'main' into maven/access
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf authored Apr 15, 2024
2 parents 5c9ef9e + f44a710 commit 222b7be
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cmds/ocm/commands/common/options/keyoption/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (o *Option) AddFlags(fs *pflag.FlagSet) {
fs.StringArrayVarP(&o.publicKeys, "public-key", "k", nil, "public key setting")
fs.StringArrayVarP(&o.privateKeys, "private-key", "K", nil, "private key setting")
fs.StringArrayVarP(&o.issuers, "issuer", "I", nil, "issuer name or distinguished name (DN) (optionally for dedicated signature) ([<name>:=]<dn>")
fs.StringArrayVarP(&o.rootCAs, "ca-cert", "", nil, "additional root certificate authorities")
fs.StringArrayVarP(&o.rootCAs, "ca-cert", "", nil, "additional root certificate authorities (for signing certificates)")
}

func (o *Option) Configure(ctx clictx.Context) error {
Expand Down
28 changes: 27 additions & 1 deletion cmds/ocm/commands/misccmds/hash/sign/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package sign

import (
"crypto/x509"
"crypto/x509/pkix"
"fmt"
"strings"
Expand Down Expand Up @@ -36,6 +37,7 @@ type Command struct {

pubFile string
rootFile string
rootCAs []string

stype string
priv signutils.GenericPrivateKey
Expand Down Expand Up @@ -72,7 +74,9 @@ $ ocm sign hash key.priv SHA-256:810ff2fb242a5dee4220f2cb0e6a519891fb67f2f828a6c
func (o *Command) AddFlags(set *pflag.FlagSet) {
set.StringVarP(&o.stype, "algorithm", "S", rsa.Algorithm, "signature algorithm")
set.StringVarP(&o.pubFile, "publicKey", "", "", "public key certificate file")
set.StringVarP(&o.rootFile, "rootCerts", "", "", "root certificates file")
set.StringVarP(&o.rootFile, "rootCerts", "", "", "root certificates file (deprecated)")
set.StringArrayVarP(&o.rootCAs, "ca-cert", "", nil, "additional root certificate authorities (for signing certificates)")

}

func (o *Command) Complete(args []string) error {
Expand Down Expand Up @@ -109,6 +113,28 @@ func (o *Command) Complete(args []string) error {
}
}

if len(o.rootCAs) > 0 {
var list []*x509.Certificate
for _, r := range o.rootCAs {
data, err := utils2.ReadFile(r, o.FileSystem())
if err != nil {
return errors.Wrapf(err, "root CA")
}
certs, err := signutils.GetCertificateChain(data, false)
if err != nil {
return errors.Wrapf(err, "root CA")
}
list = append(list, certs...)
}
if o.roots != nil {
for _, c := range list {
o.roots.(*x509.CertPool).AddCert(c)
}
} else {
o.roots = list
}
}

o.priv, err = utils2.ReadFile(args[0], o.FileSystem())
if err != nil {
return err
Expand Down
11 changes: 0 additions & 11 deletions cmds/ocm/commands/ocmcmds/common/addhdlrs/rscs/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,5 @@ func (r *ResourceSpec) Validate(ctx clictx.Context, input *addhdlrs.ResourceInpu
if err := compdescv2.ValidateResource(fldPath, rsc, false); err != nil {
allErrs = append(allErrs, err...)
}

if input.Access != nil {
if r.Relation == metav1.LocalRelation {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("relation"), "access requires external relation"))
}
}
if input.Input != nil {
if r.Relation != metav1.LocalRelation {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("relation"), "input requires local relation"))
}
}
return allErrs.ToAggregate()
}
2 changes: 1 addition & 1 deletion docs/reference/ocm.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ocm [<options>] <sub command> ...

```
-X, --attribute stringArray attribute setting
--ca-cert stringArray additional root certificate authorities
--ca-cert stringArray additional root certificate authorities (for signing certificates)
--config stringArray configuration file
--config-set strings apply configuration set
-C, --cred stringArray credential setting
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ocm_add_componentversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ script with the <code>script</code> option family.


<pre>
$ ocm add componentversions &dash;&dash;file ctf &dash;&dash;version 1.0 component-constructor.yaml
$ ocm add componentversions &dash;&dash;file ctf &dash;&dash;version 1.0 component&dash;constructor.yaml
</pre>


Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ocm_sign_componentversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ componentversions, componentversion, cv, components, component, comps, comp, c

```
-S, --algorithm string signature handler (default "RSASSA-PKCS1-V1_5")
--ca-cert stringArray additional root certificate authorities
--ca-cert stringArray additional root certificate authorities (for signing certificates)
-c, --constraints constraints version constraint
-H, --hash string hash algorithm (default "SHA-256")
-h, --help help for componentversions
Expand Down
9 changes: 5 additions & 4 deletions docs/reference/ocm_sign_hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ ocm sign hash <private key file> <hash> [<issuer>]
### Options

```
-S, --algorithm string signature algorithm (default "RSASSA-PKCS1-V1_5")
-h, --help help for hash
--publicKey string public key certificate file
--rootCerts string root certificates file
-S, --algorithm string signature algorithm (default "RSASSA-PKCS1-V1_5")
--ca-cert stringArray additional root certificate authorities (for signing certificates)
-h, --help help for hash
--publicKey string public key certificate file
--rootCerts string root certificates file (deprecated)
```

### Description
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ocm_verify_componentversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ componentversions, componentversion, cv, components, component, comps, comp, c
### Options

```
--ca-cert stringArray additional root certificate authorities
--ca-cert stringArray additional root certificate authorities (for signing certificates)
-c, --constraints constraints version constraint
-h, --help help for componentversions
-I, --issuer stringArray issuer name or distinguished name (DN) (optionally for dedicated signature) ([<name>:=]<dn>
Expand Down

0 comments on commit 222b7be

Please sign in to comment.