sign.go 883 B

1234567891011121314151617181920212223242526
  1. package signer
  2. import (
  3. "github.com/langgenius/dify-plugin-daemon/internal/core/license/private_key"
  4. "github.com/langgenius/dify-plugin-daemon/internal/utils/encryption"
  5. "github.com/langgenius/dify-plugin-daemon/pkg/plugin_packager/signer/withkey"
  6. )
  7. /*
  8. DifyPlugin is a file type that represents a plugin, it's designed to based on zip file format.
  9. When signing a plugin, we use RSA-4096 to create a signature for the plugin and write the signature
  10. into comment field of the zip file.
  11. */
  12. // SignPlugin is a function that signs a plugin
  13. // It takes a plugin as a stream of bytes and signs it with RSA-4096 with a bundled private key
  14. func SignPlugin(plugin []byte) ([]byte, error) {
  15. // load private key
  16. privateKey, err := encryption.LoadPrivateKey(private_key.PRIVATE_KEY)
  17. if err != nil {
  18. return nil, err
  19. }
  20. return withkey.SignPluginWithPrivateKey(plugin, privateKey)
  21. }