-
Notifications
You must be signed in to change notification settings - Fork 350
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
Added support to read multiple public keys from a PEM file #22
Added support to read multiple public keys from a PEM file #22
Conversation
@@ -220,6 +220,57 @@ public class SwiftyRSA: NSObject { | |||
return try addKey(data, isPublic: false) | |||
} | |||
|
|||
/// The regular expression used to find public key armor | |||
let publicKeyRegexp : NSRegularExpression! = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the caching of the regex here. However we should avoid forced-unwraps at all costs. Can you make publicKeyRegexp
an optional, and guard
it in publicKeysFromString
?
@greenantdotcom Thanks a lot! This is great. Added a couple comments inline. Can you also update the CHANGELOG.md so we keep track of changes? Thank you. |
defe8aa
to
db67bdb
Compare
For a usecase where we may have multiple public keys that our content might have been signed with, we wanted to put multiple public keys into a single file, much like you may have multiple SSL certs in a chain file. This method parses out any data between `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----`, and then uses `publicKeyFromPEMString` to try to parse it. Tests added for a really insane usecases, an empty string, and reading one of the test private keys for fun. All added code has 100% coverage, and the new method is commented.
db67bdb
to
1aa9a06
Compare
@ldiqual Should be done! |
@greenantdotcom Perfect! I'm merging this now. Thank you so much for implementing this. I've sent you an invite to join the SwiftyRSA maintainers group -- no pressure to accept! Feel free to get back to me if you have any question. |
* Make SwiftyRSA compile with Swift 3.0 * Fixed all errors + warnings * Fix spelling * Added support to read multiple public keys from a PEM file (#22) For a usecase where we may have multiple public keys that our content might have been signed with, we wanted to put multiple public keys into a single file, much like you may have multiple SSL certs in a chain file. This method parses out any data between `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----`, and then uses `publicKeyFromPEMString` to try to parse it. Tests added for a really insane usecases, an empty string, and reading one of the test private keys for fun. All added code has 100% coverage, and the new method is commented. * Added targets for watchOS and tvOS (#23) - Added additional targets for watchOS and tvOS platforms - Tests pass on tvOS - Changed the master `SwiftyRSA.h` file to pull in Foundation and not UIKit/Cocoa since those frameworks aren't needed - The current CI pipeline doesn't assume multiple targets/schemes, so I refactored `.travis.yml` to allow for AppleTV, iOS, and watchOS targets, and based on how Alamofire does theirs for multiple platform support - Updated `podspec` to show multiple platform support - Also raised iOS version to 8.3 since Travis platform doesn't seem to have support for iOS 8.0-8.2 * Updated changelog * Bump to 0.4.0 * Update to Xcode 8.0 beta 4 * Migrate to Xcode 8 beta 6 * Don't reduce maximum block size when padding is `none` Closes #29 * Update CHANGELOG.md #29 * Fix OSStatus -34018 on iOS 10 * Update travis to support xcode 8
For a usecase where we may have multiple public keys that our content might have been signed with, we wanted to put multiple public keys into a single file, much like you may have multiple SSL certs in a chain file.
This method parses out any data between
-----BEGIN PUBLIC KEY-----
and-----END PUBLIC KEY-----
, and then usespublicKeyFromPEMString()
to try to parse it.Tests added for a really insane usecases, an empty string, and reading one of the test private keys for fun. All added code has 100% coverage, and the new method is commented.