How do you generate your RSA Private and Public keys for VodaPay Mini-Programs Authentication? - vodapay-miniprogram

I am currently developing a mini-program for Vodapay and I need to generate the RSA key pairs to be able to sign my requests to the Vodapay backend.
Is there a recommended method or suggested tools I should use in order to generate my public-private key-pair for my VodaPay mini-program?

I managed to figure this out, the keys need to be generated through open SSL and they need to be stored as a .pem file
The bash commands required to get the keys are as follows, it will create the keys
Create RSA 2048 Keysopenssl genrsa -out rsa_2048_key.pem 2048
Export Public Keyopenssl rsa -in rsa_2048_key.pem -out rsa_public_key.pem -pubout
Export Private Key with PKCS#8 Encodeopenssl pkcs8 -topk8 -in rsa_2048_key.pem -out rsa_private_key.pem -nocrypt

Related

How do I convert a SSH2 PUBLIC KEY (rsa-key file) to PEM? (Base-64 encoded public key of X.509 certificate)

I have a private/public key that was generated by Putty in the following format:
SSH2 PUBLIC KEY rsa-key
However, I am trying to get it to work with Docebo API using the JWT Grant Type, which requires a different format (according to this post).
How would I convert my key(s) to work with that format? Is there a way within Putty?
I figured out the steps to take to get the proper format of key using OpenSSL:
openssl genrsa -out private.key 1024
openssl req -new -x509 -key private.key -out publickey.cer
openssl x509 -in publickey.cer -out publickey.pem

ruby openssl smime encryption

I am looking for ruby code to mimic below openssl smime encryption. I looked up other related topics but mostly were around signing. In snippet below cert.pem is a PEM-encoded X.509 certificate containing the PEM public key. token.txt file is the file to be encrypted.
openssl smime -encrypt -out encrypted.p7m -in token.txt cert.pem
Figured it.
token_plain_text = File.read("/path/to/token.txt")
cert = X509::Certificate.new("/path/to/cert.pem")
encrypted_object = OpenSSL::PKCS7.encrypt([cert], token_plain_text)
Got the encrypted string by outputting above object to string.
encrypted_str = encrypted_object.to_str

How to encrypt with both the private key and public key [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have this bash script
#generate key
openssl genrsa -out key.pem 2048
openssl rsa -in key.pem -text -noout
#save public key in pub.pem file
openssl rsa -in key.pem -pubout -out pub.pem
openssl rsa -in pub.pem -pubin -text -nout
#encrypt data
openssl rsautl -encrypt -inkey pub.pem -pubin -in license.json -out license_encrypted.json
#decrypt data
openssl rsautl -decrypt -inkey key.pem -in license_encrypted.json
In the code you can see I encrypt the file using the public key and decrypt using the private key, I need to know how to encrypt using both the private key and the public key. Is this possible. Should I decrypt using the private key or can idecrypt using the public key, this is in regards to software licenses I am trying to encrypt
I need to know how to encrypt using both the private key and the public key.
This makes no sense.
In public key cryptography, every party has a key pair composed of a public key and a private key. To encrypt a message for someone, you use his public key; he'll then use his private key to decrypt the message.
Your client should therefore generate a key pair once (preferably, this should be done automatically) and then send you his public key, with which you'll encrypt the license file and send it back to him.

Convert key and certificate

I am using Mac OS X. I have the following files
key.rtf
cert.rtf
These files are PEM encoded and contain the key and the certificate in text form (-----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----).
How can I:
decrypt the private key with the passphrase I used to encrypt it and get it back in text form?
get both files in PEM format as text (!) back?
The PEM encoding makes problems - if the files are stored as .key, .cert or anything like this, it works properly. But I need the text.
Thanks!
It is possible with this command: openssl rsa -in cert.pem -out server.key (I converted the files to a cert.pem file before).

Heroku No valid, non-passphrase-protected keys given error

I have this files:
AddTrustExternalCARoot.crt
STAR_mydomain_com.crt
TrustedSecureCertificateAuthority5.crt
USERTrustRSAAddTrustCA.crt
domain.key
domain.key is passphrase protected and it was generated during creation of CSR files (files that were required to get .crt files from certificate provider. I tried:
heroku certs:update certs/STAR_mydomain_com.crt certs/domain.key
But I get following error:
! No valid, non-passphrase-protected keys given.
How I can generate valid crt/key for heroku? (I tried all other crt files with domain key but they are not valid domain certificates.
domain.key was generated with following command:
openssl genrsa -des3 -out domain.key 2048
Here's how to remove a passphrase from a private key:
openssl rsa -in certs/domain.key -out certs/domain-nopassphrase.key
You'll need to enter the current passphrase on the private key. If prompted for a passphrase on the new key, do not enter one (just press enter).
You can then update your SSL endpoint using your cert + this new key:
heroku certs:update certs/*.crt certs/domain-nopassphrase.key

Resources