nineep opened a new pull request, #708:
URL: https://github.com/apache/pulsar-site/pull/708
golang client: only RSA keys are supported
func (d *DefaultMessageCrypto) addPublicKeyCipher(keyName string, keyReader
KeyReader) error {
d.cipherLock.Lock()
defer d.cipherLock.Unlock()
if keyName == "" || keyReader == nil {
return fmt.Errorf("keyname or keyreader is null")
}
// read the public key and its info using keyReader
keyInfo, err := keyReader.PublicKey(keyName, nil)
if err != nil {
return err
}
parsedKey, err := d.loadPublicKey(keyInfo.Key())
if err != nil {
return err
}
// try to cast to RSA key
rsaPubKey, ok := parsedKey.(*rsa.PublicKey)
if !ok {
return fmt.Errorf("only RSA keys are supported")
}
encryptedDataKey, err := rsa.EncryptOAEP(sha1.New(), rand.Reader,
rsaPubKey, d.dataKey, nil)
if err != nil {
return err
}
d.encryptedDataKeyMap.Store(keyName, NewEncryptionKeyInfo(keyName,
encryptedDataKey, keyInfo.Metadata()))
return nil
}
<!--
### Contribution Checklist
- PR title format should be *[type][component] summary*. For details, see
*[Guideline - Pulsar PR Naming
Convention](https://pulsar.apache.org/contribute/develop-semantic-title/)*.
-->
<!-- Either this PR adds a doc for a code PR, -->
This PR adds doc for #xyz
<!-- or fixes a doc issue -->
This PR fixes #xyz
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. Please attach the local
preview screenshots (run `./preview.sh` at root path) to your PR description,
or else your PR might not get merged. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update
later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]