Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] - Encode with RS256 using string data of a private key #96

Closed
dittmarconsulting opened this issue Sep 24, 2018 · 4 comments
Closed
Labels
question Further information is requested
Projects

Comments

@dittmarconsulting
Copy link

Hi all,

Is it possible to sign a RS256 JWT token with a string of the private keys similar to

"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAtN7LQq7l9a9....SUug==\n-----END RSA PRIVATE KEY-----\n"

Many thanks in advance

@vzsg
Copy link
Member

vzsg commented Sep 24, 2018

You can initialize an RSAKey from the PEM-encoded private key using this initializer, which you can then pass to JWTSigner.rs256.

@dittmarconsulting
Copy link
Author

dittmarconsulting commented Sep 27, 2018

Hi @vzsg,

Thank you for the reply.

I'm not really a iOS developer but I understand the code. Unfortunately my project is written in Objective-C (for React-Native).

Since the project doesn't contain any .h header files I created my own bridging header like that:

@class RSAKey;
@interface C-RSAKey: NSObject;
- (RSAKey *)returnSwiftObject;
@end

Unfortunately I'm stuck here

C-RSAKey *rsaKey = [[C-RSAKey alloc] init];
???? public static func `private`(pem: LosslessDataConvertible)

Is that possible to use this library in Objective-C at all?

Thanks in advance

@vzsg
Copy link
Member

vzsg commented Sep 27, 2018

This library is for server-side Swift development only, not compatible with iOS (thus React Native) projects at all. What is the use case?

@dittmarconsulting
Copy link
Author

dittmarconsulting commented Sep 27, 2018

Hi @vzsg,

I work on a blockchain app in RN. I have a wallet (RSA private/public key) and the JWT token implementation in Android, which was very easy. (JAVA & Javascript is my background)

I'm struggling to find a JWT library for iOS that deals with string representation of the private key. According to the research I did, iOS insists to extract the private key from a .p12 file instead. This library is one of them https://github.com/yourkarma/JWT

@tanner0101 tanner0101 added the question Further information is requested label Jul 30, 2020
@tanner0101 tanner0101 added this to To Do in Vapor 3 via automation Jul 30, 2020
@tanner0101 tanner0101 moved this from To Do to Done in Vapor 3 Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
No open projects
Vapor 3
  
Done
Development

No branches or pull requests

3 participants