Skip to content

feat: Enable offline encryption cert listing and version selection support during contract encryption#118

Merged
Sashwat-K merged 5 commits into
ibm-hyper-protect:mainfrom
Priyanga-M-001:built-in-enc-certs
May 25, 2026
Merged

feat: Enable offline encryption cert listing and version selection support during contract encryption#118
Sashwat-K merged 5 commits into
ibm-hyper-protect:mainfrom
Priyanga-M-001:built-in-enc-certs

Conversation

@Priyanga-M-001
Copy link
Copy Markdown
Contributor

@Priyanga-M-001 Priyanga-M-001 commented May 10, 2026

Description

This PR adds support for specifying encryption certificate versions in contract-cli commands while encrypting a contract and introduces a new command to list available certificate versions.

Related Issue

Fixes #116

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Code refactor

Testing

Describe the tests you ran and how to reproduce them

  • make test passes
  • make fmt applied (no formatting changes needed)
  • New tests added for new functionality (if applicable)

The functionality is tested using CLI tool and here are the results :

priya@macbookpro contract-cli % ./contract-cli encrypt --in samples/contract.yaml --os ccco --ver 25.10.0
env: hyper-protect-basic.a8YzKhUmzW2yzkxTsXqpSBboXd4...
envWorkloadSignature: P4WIGTwAiQ2V7ZI8geR4lqwsXJ6jdo...
workload: hyper-protect-basic.aL63ffPj9XfEfGNeL7ahEN702...
priya@macbookpro contract-cli % ./contract-cli encrypt --in samples/contract.yaml                        
env: hyper-protect-basic.ZNd6fX/hSC5S4iFZN3I8luIPP92u...
envWorkloadSignature: WpWeDuQI6XGyniq3R0KxR4lGakY...
workload: hyper-protect-basic.DzByTO5TPB/leBNrLCljYAt+...`
priya@macbookpro contract-cli % ./contract-cli list-encryptioncert-versions       
{"ccco":["25.12.0","25.10.0"],"ccrt":["26.2.0","25.11.0","25.8.1"],"ccrv":["26.4.1","25.11.0","25.8.1"]}
priya@macbookpro contract-cli % ./contract-cli list-encryptioncert-versions --os ccrv --format yaml
ccrv:
    - 26.4.1
    - 25.11.0
    - 25.8.1

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • I have updated the documentation
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass

@Priyanga-M-001
Copy link
Copy Markdown
Contributor Author

What's Changed

New Features

1. Certificate Version Selection (--ver flag)

  • Added --ver flag to all encryption commands: encrypt, encrypt-string, and base64-tgz
  • Users can now specify a specific certificate version (e.g., 26.2.0, 25.11.0) from the available list instead of always using the latest
  • Empty/omitted flag defaults to latest version for backward compatibility

2. New Command: list-encryptioncert-versions

  • Lists all available encryption certificate versions for each platform
  • Supports JSON and YAML output formats via --output flag
  • Supports platform filtering via --os flag (ccrt, ccrv, ccco, or hpvs as legacy alias for ccrt)

Examples:

./contract-cli list-encryptioncert-versions --output json
./contract-cli list-encryptioncert-versions --os ccrt --output yaml
./contract-cli encrypt --in samples/contract.yaml --os ccco --ver 25.10.0

Dependencies

  • go.mod - Updated to contract-go v2.23.0
  • go.sum - Updated checksums

Test coverage includes:

  • Certificate version selection with valid versions
  • Default behavior (empty version = latest)
  • Platform-specific certificate retrieval
  • JSON and YAML output formats for list command
  • Platform filtering in list command

@Sashwat-K Sashwat-K requested a review from vikas-sharma24 May 11, 2026 17:16
@Sashwat-K
Copy link
Copy Markdown
Collaborator

Hey @Rohit-Singh43-1 @vikas-sharma24 , Please review this PR.

Copy link
Copy Markdown
Contributor

@Rohit-Singh43-1 Rohit-Singh43-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Priyanga-M-001 for feature update, Changes overall Looks good to me , Just added few readme comments , Please have look of those

Comment thread docs/README.md

Output:
```yaml
ccco:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Priyanga-M-001 for CCCO in contract-go only 2 certs are uploaded , Can you please update the example out here it show one extra 25.7.1

https://github.com/ibm-hyper-protect/contract-go/tree/main/encryption/ccco

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch !, thanks for bringing this up. I'll update it

Comment thread docs/README.md Outdated

#### Use Cases

1. **Discover Available Versions**: Find out which certificate versions are embedded in your CLI installation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

certificates are embedded in contract-go library , Please update
embedded in your CLI installation --> embedded in contract-go library

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rohit-Singh43-1 , all the functions internally call contract-go, but for a user, contract-cli is the front face. Hence, I hope no changes are needed here.
@Sashwat-K can confirm once.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Rohit-Singh43-1 , make @Priyanga-M-001 said makes sense. The customer only sees the CLI documentation.

Comment thread cmd/base64Tgz.go
Comment thread cmd/listCertVersions.go Outdated
"github.com/spf13/cobra"
)

// listCertVersionsCmd represents the list-cert-versions command
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment with correct command list-encryptioncert-versions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this is not updated yet @Priyanga-M-001

Comment thread cmd/listCertVersions.go Outdated
if err != nil {
log.Fatal(err)
}
fmt.Println("Successfully stored certificate versions")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can mention encryption certificate as in future will have one more command to store attestation certificate.

Comment thread cmd/listCertVersions.go
"",
"",
listCertVersions.FormatFlagDescription,
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add SetCustomHelpTemplate and SetCustomErrorTemplate function as well.
Take reference of other command.
This is used if someone give wrong command or flag

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check this @Priyanga-M-001

Comment thread cmd/listCertVersions.go
sampleListCcrvCertVersionsCommand = []string{listCertVersions.ParameterName, "--os", "ccrv"}
sampleListCccoCertVersionsCommand = []string{listCertVersions.ParameterName, "--os", "ccco"}
sampleListInvalidPlatformCommand = []string{listCertVersions.ParameterName, "--os", "invalid"}
sampleListCaseInsensitiveCommand = []string{listCertVersions.ParameterName, "--os", "CCRT"}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add one testcase for hpvs flag as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread cmd/listCertVersions_test.go Outdated
Comment thread docs/README.md
Comment thread docs/README.md
Comment thread docs/README.md
Comment thread docs/README.md Outdated

#### Examples

**List all available certificate versions in JSON format (default):**
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encryption certificate

Comment thread docs/README.md
Comment thread lib/base64Tgz/base64Tgz.go
Comment thread lib/encrypt/encrypt.go
Comment thread lib/encryptString/encryptString.go
Comment thread README.md Outdated
--in docker-compose.yaml \
--os ccco \
--ver 25.12.0 \
--encrypt
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no --encrypt flag in base64-tgz command

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks, updating it

Comment thread lib/listCertVersions/listCertVersions.go
Comment thread lib/listCertVersions/listCertVersions.go
@Priyanga-M-001
Copy link
Copy Markdown
Contributor Author

@Sashwat-K @vikas-sharma24 @Rohit-Singh43-1 , I have pushed the changes made for addressing the review comments. Please review and resolve the conversation if all expected changes are good

Copy link
Copy Markdown
Contributor

@Rohit-Singh43-1 Rohit-Singh43-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM , Thanks @Priyanga-M-001 for the changes.

Copy link
Copy Markdown
Collaborator

@Sashwat-K Sashwat-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to good @Priyanga-M-001 . @vikas-sharma24 would you confirm as well?

@Sashwat-K Sashwat-K merged commit 4254431 into ibm-hyper-protect:main May 25, 2026
4 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.23.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Sashwat-K
Copy link
Copy Markdown
Collaborator

Thank you @Priyanga-M-001 for this feature!

@Priyanga-M-001
Copy link
Copy Markdown
Contributor Author

Thanks everyone for the approvals and thank you @Sashwat-K for merging the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add support to list offline available encryption certificate

4 participants