Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple certs support, close #31 #48

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

zhao-kun
Copy link
Collaborator

@zhao-kun zhao-kun commented Jun 18, 2021

Support multiple certs configuration

YAML support breaking a string in multiple lines natively [1], I think that wrapping certs/keys content with base64 is redundant. So it's just good with raw contents for these.

Configuration items of certsBase64 and keysBase64 are preserved for backward compatible
Add certs and keys for multiple certs configuration.

Configurations look like:

certs:
  dev.megaease.cn: |
    -----BEGIN CERTIFICATE-----
    MIIFJDA0BAygAwIBAgISA/r3vmvbrVvYUa3aDvyfwl/MMA0GCSqGSIb3DQEBCwUA
    ....
    feaTfKfeeUXTj/6VCM/p1geUXicA==
    -----END CERTIFICATE-----
keys:
   dev.megaease.cn: |
     -----BEGIN PRIVATE KEY-----
     M4FDvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDz94xC9T0qpg2O
     ...
     feaTfKfeeUXTj/6VCM/p1geUXicA==
     -----END PRIVATE KEY-----

The change has been verified by [2][3]

[1] https://yaml-multiline.info/
[2] https://dev.megaease.cn/megacloud/app/
[3] https://api.dev.megaease.cn/megacloud/app/

@zhao-kun zhao-kun added the enhancement New feature or request label Jun 18, 2021
@zhao-kun zhao-kun added this to In progress in Easegress Project via automation Jun 18, 2021
@zhao-kun zhao-kun added this to the v1.0.1 milestone Jun 18, 2021
if spec.KeyBase64 == "" {
return fmt.Errorf("keyBase64 is empty when https enabled")
if spec.CertBase64 == "" && spec.KeyBase64 == "" && spec.Certs == nil && spec.Keys == nil {
return fmt.Errorf("certBase64, keyBase64, certs, keys can't be both empty when https enabled")
Copy link
Contributor

Choose a reason for hiding this comment

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

We give the direct failure reason instead of xxx can't yyy.
Propose certBase64/keyBase64, certs/keys are both empty when https enabled

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

}
certificates = append(certificates, cert)
} else {
logger.Warnf("certs %s hasn't secret corresponded to it", k)
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, make it strict, just return error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

Easegress Project automation moved this from In progress to Reviewer approved Jun 18, 2021
KeyBase64 string `yaml:"keyBase64" jsonschema:"omitempty,format=base64"`

// Certs saved as map, key is domain name, value is cert
Certs map[string]string `yaml:"certs" jonschema:"omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

jonschema should be jsonschema.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Updated.

Copy link
Contributor

@benja-wu benja-wu left a comment

Choose a reason for hiding this comment

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

LGTM

@benja-wu benja-wu merged commit 71e3dfe into easegress-io:main Jun 18, 2021
Easegress Project automation moved this from Reviewer approved to Done Jun 18, 2021
fengyie007 pushed a commit to fengyie007/easegress that referenced this pull request Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants