Verify signature generated online with public key - x509certificate

I work with (browser token signing ) to sign a text with x509 certificate. I'd like to verify that the Generated signature is valid or not.
is there any tools to verify the Generated signature online or other way????
test signature

Related

Signing an x509 certificate without direct access to private key (stored in aws kms/hsm)

I want to sign an X509 certificate whose keys I cannot access directly(stored in KMS/HSM).
I thought of a way to sign the certificate with any random private key so that the certificate can be generated successfully, after that, I can pass the payload of the certificate to the KMS/HSM for signing, and the signature that will be given will be set in the previously created certificate. But I am not able to do so. Can someone help me how to achieve this with the java code?

Firebase & Postman | Generate JWT for Google Identity OAuth 2.0 token

I am trying to execute some administrative tasks on my Cloud Firestore (upload some data, ... etc.). I read through the documentations here
Use a Google Identity OAuth 2.0 token and a service account to authenticate requests from your application, such as requests for database administration.
This referred to the documentation here on how to make Authorized API Call after generating JWT. I am struggling with generating the JWT.
This is what I tried:
I formed the header and the claim set
{"alg":"RS256","typ":"JWT"}.
{
"iss":"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5#developer.gserviceaccount.com",
"scope":"https://www.googleapis.com/auth/prediction",
"aud":"https://oauth2.googleapis.com/token",
"exp":1328554385,
"iat":1328550785
}
Went to https://jwt.io/ to generate JWT with RSA256. It asks for public key and private key. I understand the private key can be generated in json formate from service account I created under https://console.cloud.google.com/iam-admin/serviceaccounts. However, I am not sure where to obtain the public key. jwt.io does not generate jwt. I only get 'invalid signature'.
There are many examples in the web using SDK or libraries. However, I could not see any example on how to generate JWT manually (if that is possible at all) to use it with Postman. Any idea?
Thanks to #JohnHanley. I managed to generate the token. This is not entirely withing Postman (I am still relying on jwt.io to generate the jwt).
after creating service account here. add a key and download the p12 file (not json). The default secret is notasecret
convert p12 to pem and extract the public key:
$openssl pkcs12 -in postman-admin-private.p12 -out postman-admin-private.pem -nodes
$openssl rsa -in postman-admin-private.pem -outform PEM -pubout -out postman-admin-public.pem
Open both pem files and copy the private and public keys into jwt.io (using RSA256 option)
Make sure you use the email address of the service account in iss field
Here is the request in postman:
curl --location --request POST 'https://oauth2.googleapis.com/token?grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion='{generated jwt}'
next would be to make it entirely within Postman. I have not tried that but this post seems to be an option

Firebase token verification on server

I am trying to implement an authentication/authorization system using firebase and I am struggling with the last part of the authorization flow, which is, enabling my server to verify the validity of a token.
There are two ways to perform this:
Validate the token using the Admin SDK of firebase, where essentially a server communicates with Firebase and validates a token (safe option)
Validate the token using a third-party JWT library.
My question has to do with option (2), which according to documentation is perfectly feasible. The question is, how is this safe? Everything included in the token-validation process is public according to this:
Finally, ensure that the ID token was signed by the private key corresponding to the token's kid claim. Grab the public key from https://www.googleapis.com/robot/v1/metadata/x509/securetoken#system.gserviceaccount.com and use a JWT library to verify the signature. Use
If the token is public, and the key for validating it is public, who guarantees that the token is genuine?
Probably there is something related to JWTs that I am missing?
PS. I have already implemented option (1) with remote validation, but this will significantly affect the application performance.
You can verify validity of a token with the public key, but you can only create tokens with the private key.
As their names imply:
Your private key should only be used in trusted environments, such as your development machine, a server you control, or Cloud Functions. So those are the only places where you can generate auth tokens.
The public key however can be shared with others, which means that they can use it to ensure that the token is valid.

Is encrypting with private key instead of signing a bad idea?

I am using a local URL scheme to submit a payload to the client when a user clicks a link and have to make sure that this is only used in my specific web application.
So I am using a key pair, encrypting the payload on the server using the private key, generating a link that the protocol handler on the client can decrypt using the public key, verifying that the payload should be processed.
So is it less secure to send a private-key-encrypted payload instead of a cleartext payload plus signature (and if yes, why)?
Found out that there are other Stack Exchange sites that answer this question very well:
https://crypto.stackexchange.com/questions/2123/rsa-encryption-with-private-key-and-decryption-with-a-public-key
https://security.stackexchange.com/questions/11879/is-encrypting-data-with-a-private-key-dangerous
I should have searched a little bit longer before asking.
What you are doing is signing!
Encrypting is when a payload is being concealed with one’s public key and later decrypted with a private key. When I want to send you a secret message, I will take your public key (because I know it) and encrypt my message. This will make sure that only you can decrypt it with your private key.
Signing works vice versa. If during encryption I want to make sure that only you can decrypt me message, with signing I want to make sure that all recipients of the message can be sure in its authenticity. If you encrypt something with your private (signing), anyone with your public key can decrypt it and verify its sender.
In your case, if you just want to prove your identity (like certificates, jwt tokens, etc.), you would need to use signing methods. If you want to transfer payload securely, use encryption.
Hope this helps!

Where do I find a key that JWT is signed with?

I develop phoenix app that uses Firebase as an external authentication service. I use Joken library. It requires me to use function with_signer that needs a cryptographic key. I suppose this is the key that JWT was signed with by Firebase. The question is - am I right in my assumptions? And more importantly - where do I find this key?
Firebase should publish a public key at a well known address that you can use to validate the JWTs.
The docs suggest:
Finally, ensure that the ID token was signed by the private key
corresponding to the token's kid claim. Grab the public key from
https://www.googleapis.com/robot/v1/metadata/x509/securetoken#system.gserviceaccount.com
and use a JWT library to verify the signature. Use the value of
max-age in the Cache-Control header of the response from that endpoint
to know when to refresh the public keys.

Resources