-
Notifications
You must be signed in to change notification settings - Fork 349
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
publicKeyFromPEMString error code 500 #2
Comments
@youdy3000 Thanks for the kind words! Would you mind sending me an example of public key that fails with |
@youdy3000 Bump |
@ldiqual nothing clever from my side. The pub key that generated the error was created using your readme instructions. $ ssh-keygen -t rsa -f ~/mykey -N '' |
@youdy3000 I see. I'm unable to reproduce on my end, would you mind sending me your playground as well as the keys you're using? (make sure to use new keys so you don't leak anything). I'd suggest https://transfer.sh/. |
Hi @ldiqual, I have the same problem. Your test key pass the test.
or this one (created with CommonCrypto) :
Will not pass the stripPublicKeyKeader function. The first one fails at the test |
@quentinlesceller Interesting, maybe it's 1024bits vs 2048bits that doesn't work. Will take a look. |
Update on this issue. I investigated for a bit, and I can't really find why your public keys are missing the necessary bytes. However I stumbled upon this post on Stackoverflow that explains the "right way" to import public keys (by creating a self-signed certificate), and I'm leaning towards modifying SwiftyRSA to use this method. I'll give it a shot when I have a bit more time. Thanks for your patience! |
Hi @ldiqual , I also investigated this issue and tried a lot of different librairies in order to import a 2048 RSA Public key. |
@quentinlesceller Thanks a lot for sharing! Will take a look |
@quentinlesceller I tried to strip the key headers with RSAUtils and it failed on both of your keys. I also tried with |
Yes sorry, I was obviously talking about |
@quentinlesceller I think I figured it out. Your key doesn't have a header at all, as you can see in this ASN.1 parser: https://lapo.it/asn1js/#3082010A0282010100C1A0DFA367FBC2A5FD6ED5A071E02A4B0617E19C6B5AD11BB61192E78D212F10A7620084A3CED660894134D4E475BAD7786FA1D40878683FD1B7A1AD9C0542B7A666457A270159DAC40CE25B2EAE7CCD807D31AE725CA394F90FBB5C5BA500545B99C545A9FE08EFF00A5F23457633E1DB84ED5E908EF748A90F8DFCCAFF319CB0334705EA012AF15AA090D17A9330159C9AFC9275C610BB9B7C61317876DC7386C723885C100F774C19830F475AD1E9A9925F9CA9A69CE0181A214DF2EB75FD13E6A546B8C8ED699E33A8521242B7E42711066AEC22D25DD45D56F94D3170D6F2C25164D2DACED31C73963BA885ADCB706F40866B8266433ED5161DC50E4B3B0203010001 So I think all we need to do is send the raw key if we don't detect a header, I'll try to experiment with this. |
@quentinlesceller I got it to work by skipping the header strip if there is no header at all. I'll commit my changes and add more tests to handle this case |
Make the library dynamic
NSFPIO-925 Added support of the Swift Package Manager
Hi @ldiqual, thanks for this library. Very cool.
Is there an issue with the latest commit and publicKeyFromPEMString(pubString)?
In my Swift playground, I found the following:
privateKeyFromPEMString works.
publicKeyFromDERData works.
publicKeyFromPEMString fails.
Example to show you the error:
let rsa = SwiftyRSA()
let pubPath: String = NSBundle.mainBundle().pathForResource("public", ofType: "pem")!
The text was updated successfully, but these errors were encountered: