-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
CSR key size = 0 when decoding, MacOS #44
Comments
Are you able to investigate this to see what's going on with the keys? I'm guessing it's something with the way the keys are created/maintained in Keychain in MacOS. If you get somewhere close to a fix, feel free to submit a PR and I will try to help with the fix |
@cbaker6 I sent you an email about the same issue on MacOS today, now I see @kynansongwork reported issue here. Do you have a fix? Pasted my code here: import Foundation print("Step 1: generate publicKey and privateKey!!!") let privateKeyAttr: [NSObject: NSObject] = [ var keyPairAttr = NSObject: NSObject var publicKey : SecKey? if statusCode == noErr && publicKey != nil && privateKey != nil {
} else { //Step 2: Set algorithm and block size let query: [String: Any] = [ var tempPublicKeyBits:CFTypeRef? let copyResultCode = SecItemCopyMatching(query as CFDictionary, &tempPublicKeyBits) guard let publicKeyBits = tempPublicKeyBits as? Data else {
} let csr2 = CertificateSigningRequest(keyAlgorithm: algorithm) //CSR with a specific key enum WhaleError: Error { |
@lihuiniu no, but if you would like to look into the comment I posted earlier in the thread
|
@cbaker6 Thanks for you response. I clean up the keychain, no miracle happen. I noticed there are issues when generate the privatekey and publickey eventhough these are generated, but not perfect as you can see in the log: Step 1: generate publicKey and privateKey!!! builtCSR2 to verify the signature after building: -----BEGIN CERTIFICATE REQUEST----- builtCSR3 without header and footer info: MIIB8jCB2wIBADCBoDEMMAoGA1UEBgwDVVNBMQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHUmVkbW9uZDEQMA4GA1UECgwHb25leXViaTENMAsGA1UECwwEeXViaTENMAsGA1UEAwwEbGh1aTEhMB8GCSqGSIb3DQEJAQwSbGh1aUBtaWNyb3NvZnQuY29tMR4wHAYDVQQNDBVsaHVpIHRlc3RpbmcgY3NyIDEyMzQwMTANBgkqhkiG9w0BAQEFAAMgADAdAgACGRyjD8kR1ISaAAUCtSEiAgAAAAAAAAAqAACgADANBgkqhkiG9w0BAQsFAAOCAQEAFuPmoU0owOGdeWVj95ZCD+NUaRUtQX/QC4JVM/6ebPb7I0EGZ52WzHEYdg93+9zhC+81vRTv4n7uJ2tn8h+xYcQR8du7uyuMmj8qOogh5Omjst9hVYzzzIeUWAt9dsj+UYnW65M9tX7B4snzTnrcWjLSCQGAb2IpxoTKy4FJBxHpdOORwGce9XWMluvSAtZhnuAyp7s7xxjyaCulULHFUYekIWDa4V8EFkGls/8yvtWKYrIdpyF9EgESVowHUWySFOT4iOAbha/4qb7vIQyEm9fJ5yq3wtNkIaM+Uk7vpp5//Va7h+Pr6TyuMu2l3nvrlW8bhVNjjWFcvPJZbARi8w== |
I checked the csr generated when run "swift test" on your main branch, all the csr show the same issue when checked for valid online at https://redkestrel.co.uk/products/decoder/ |
@cbaker6 Could you run "swift test" on the main branch, since all the csr generated in the input show invalid for me: Test Case '-[CertificateSigningRequestTests.CertificateSigningRequestTests testCreateCSRwithRSA1024KeySha1]' passed (0.552 seconds). Test Case '-[CertificateSigningRequestTests.CertificateSigningRequestTests testCreateCSRwithRSA1024KeySha256]' passed (0.244 seconds). |
@kynansongwork Have you fixed the issue? The keyPair was generated with some issues as follows, I have not fix it even though tried many options : 2021-03-07 19:59:44.076404-0600 StoryBoardSingleViewControllerMacOSApp[13816:678717] [logging-persist] cannot open file at line 44580 of [02c344acea] My. example code as follows when create MacOS APP using storyboard: import Cocoa class ViewController: NSViewController {
} |
|
Stale issue message |
Stale issue message |
Stale issue message |
Stale issue message |
Hey there.
I have been trying to generate a CSR based on your code, and for the most part it is going swimmingly. However I have noticed that when I decode the out put on Red Kestrel, the CSR is invalid and the key size is 0?
Is this something you have come across on MacOS? As when I run your test suite on on iOS, the CSR generated is fine.
The text was updated successfully, but these errors were encountered: