SSL解密未正确生成开始类型

发布于 2025-02-01 22:32:06 字数 1063 浏览 5 评论 0原文

我的上下文是,我正在使用JWT令牌流以Bitbucket管道连接到SF。 我已经能够根据需要正确生成证书和键等。我测试了它正常工作的钥匙。下一步是添加安全性,并且不想将我的密钥存储在项目中,因此我对密钥进行了加密:

openssl enc -nosalt -aes-256-cbc -in server.key -out server.key.enc -base64 -K <key-value> -iv <iv-value>

现在我将加密的server.key.enc文件存储在我的项目中,然后存储了密钥和IV值 如今,在登录到ORG之前,现在是受保护的bitbucket变量(decryption_key和decryption_iv),

我需要将server.key.enc解密至server.key.key.key.key。无法正常工作:

openssl enc -nosalt -aes-256-cbc -d -in key/server.key.enc -out key/server.key -base64 -K $DECRYPTION_KEY -iv $DECRYPTION_IV

server.key文件只有标头畸形,但页脚的生成很好

预期:

-----BEGIN RSA PRIVATE KEY-----
...........
-----END RSA PRIVATE KEY-----

got:

-��}�5��n�S�*��RIVATE KEY-----
...........
-----END RSA PRIVATE KEY-----

因此,我的管道完成了以下错误: 错误运行AUTH:JWT:GRANT:我们遇到了JSON Web令牌错误,这可能不是Salesforce CLI的问题。这是错误:错误:0909006C:PEM例程:get_name:no Start Line

似乎我在某个地方缺少一个小参数,但无法找到位置。

My context is that I am using jwt token flow to connect to SF in bitbucket pipeline.
I have been able to correctly generate a certificate and key etc as required. I tested the key it is working fine. Next step was to add security, and did not wanted to store my key in the project, thus I encrypted the key like this :

openssl enc -nosalt -aes-256-cbc -in server.key -out server.key.enc -base64 -K <key-value> -iv <iv-value>

Now I am storing the encrypted server.key.enc file in my project and then stored the key and iv value as protected bitbucket variables (DECRYPTION_KEY and DECRYPTION_IV)

Now before login to the org, I need to decrypt the server.key.enc to server.key so that I can use this file to login, but when doing so using following cmd, it is not working properly :

openssl enc -nosalt -aes-256-cbc -d -in key/server.key.enc -out key/server.key -base64 -K $DECRYPTION_KEY -iv $DECRYPTION_IV

The server.key file has only the header malformed but the footer is well generated

EXPECTED :

-----BEGIN RSA PRIVATE KEY-----
...........
-----END RSA PRIVATE KEY-----

GOT :

-��}�5��n�S�*��RIVATE KEY-----
...........
-----END RSA PRIVATE KEY-----

Thus my pipeline finish with following error :
ERROR running auth:jwt:grant: We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: error:0909006C:PEM routines:get_name:no start line

It seems like I missing a small parameter somewhere, but could not locate where.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情洁癖 2025-02-08 22:32:06

正如Topaco所建议的那样,我尝试了另一种更简单的方法来加密和解密:

加密:

openssl aes-256-cbc -a -salt -pbkdf2 -in server.key -out server.key.enc -k <password>

解密:

openssl aes-256-cbc -d -a -pbkdf2 -in server.key.enc -out server.key -k <password>

如下所述:如何使用openssl来加密/解密文件?

效果更好

As suggested by Topaco, I tried another simpler way to encrypt and decrypt :

Encrypt:

openssl aes-256-cbc -a -salt -pbkdf2 -in server.key -out server.key.enc -k <password>

Decrypt:

openssl aes-256-cbc -d -a -pbkdf2 -in server.key.enc -out server.key -k <password>

as mentioned here : How to use OpenSSL to encrypt/decrypt files?

And it works better

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文