I've tried all kinds of ways to get a SecKeyRef from the .p8 file I downloaded from my App Store Connect account. The key itself looks OK, as openssl gives this result:
openssl asn1parse -in 359UpAdminKey.p8
0:d=0 hl=3 l= 147 cons: SEQUENCE
3:d=1 hl=2 l= 1 prim: INTEGER :00
6:d=1 hl=2 l= 19 cons: SEQUENCE
8:d=2 hl=2 l= 7 prim: OBJECT :id-ecPublicKey
17:d=2 hl=2 l= 8 prim: OBJECT :prime256v1
27:d=1 hl=2 l= 121 prim: OCTET STRING [HEX DUMP]:30...
My method for creating the key is:
'- (SecKeyRef)privateKeyFromP8:(NSURL *)p8FileURL error:(NSError **)error {
// Read the .p8 file
NSData *p8Data = [NSData dataWithContentsOfURL:p8FileURL options:0 error:error];
if (!p8Data) {
return NULL;
}
// Convert P8 to base64 string, removing header/footer
NSString *p8String = [[NSString alloc] initWithData:p8Data encoding:NSUTF8StringEncoding];
NSArray *lines = [p8String componentsSeparatedByString:@"\n"];
NSMutableString *base64String = [NSMutableString string];
for (NSString *line in lines) {
if (![line containsString:@"PRIVATE KEY"]) {
[base64String appendString:line];
}
}
// Decode base64 to raw key data
NSData *keyData = [[NSData alloc] initWithBase64EncodedString:base64String options:0];
if (!keyData) {
if (error) {
*error = [NSError errorWithDomain:@"P8ImportError"
code:1
userInfo:@{NSLocalizedDescriptionKey: @"Failed to decode base64 data"}];
}
return NULL;
}
// Set up key parameters
NSDictionary *attributes = @{
(__bridge NSString *)kSecAttrKeyType: (__bridge NSString *)kSecAttrKeyTypeECSECPrimeRandom,
(__bridge NSString *)kSecAttrKeyClass: (__bridge NSString *)kSecAttrKeyClassPrivate,
(__bridge NSString *)kSecAttrKeySizeInBits: @256
};
// Create SecKeyRef from the raw key data
CFErrorRef keyError = NULL;
SecKeyRef privateKey = SecKeyCreateWithData((__bridge CFDataRef)p8Data,
(__bridge CFDictionaryRef)attributes,
&keyError);
if (!privateKey && keyError) {
*error = (__bridge_transfer NSError *)keyError;
NSError *bridgeError = (__bridge NSError *)keyError;
if (error) {
*error = bridgeError; // Pass the bridged error back to the caller
}
NSLog(@"Key Error: %@", bridgeError.localizedDescription);
}
return privateKey;
}
`
I get this error from SecKeyCreateWithData
The operation couldn’t be completed. (OSStatus error -50 - EC private key creation from data failed)
Filed a DTS incident, but they won't be back until after the New Year.
I've tried all kinds of things. Various AI chatbots, etc. Nothing seems to be working. I'm sure the problem is something elementary, but have spent hours on this with no luck.
Help, please.
Prioritize user privacy and data security in your app. Discuss best practices for data handling, user consent, and security measures to protect user information.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello --
I am developing an Authentication Plug-in for the purpose of invoking login with no user interaction (headless).
There seems to be sufficient documentation and sample code on how to implement a plug-in and mechanism, and debug the same, which is great. What I am trying to understand is exactly how to modify the login right (system.login.console) in order to accomplish my goal.
Question 1:
I had the idea of installing my mechanism as the first mechanism of the login right, and when invoked to set the username and password into the engine’s context, in the belief that this would negate the system from needing to display the login screen. I didn’t modify or remove any other mechanisms. This did not work, in the sense that the login screen was still shown. Should this work in theory?
Question 2:
I then tried modifying the login right to remove anything that interacted with the user, leaving only the following:
<array>
<string>builtin:prelogin</string>
<string>builtin:login-begin</string>
<string>builtin:forward-login,privileged</string>
<string>builtin:auto-login,privileged</string> <string>MyAuthPlugin:customauth,privileged</string>
<string>PKINITMechanism:auth,privileged</string>
<string>builtin:login-success</string>
<string>HomeDirMechanism:login,privileged</string>
<string>HomeDirMechanism:status</string>
<string>MCXMechanism:login</string>
<string>CryptoTokenKit:login</string>
</array>
The mechanisms I removed were:
<string>builtin:policy-banner</string>
<string>loginwindow:login</string>
<string>builtin:reset-password,privileged</string>
<string>loginwindow:FDESupport,privileged</string>
<string>builtin:authenticate,privileged</string>
<string>loginwindow:success</string>
<string>loginwindow:done</string>
In place of builtin:authenticate I supplied my own mechanism to verify the user’s password using OD and then set the username and password in the context. This attempt appears to have failed quite badly, as authd reported an error almost immediately (I believe it was related to the AuthEngine failing to init).
There’s very little information to go on as to what each of these mechanisms do, and which are required, etc.
Am I on the wrong track in attempting this? What would be the correct approach?
Hello, I have created an app for both iOs and Android where upon speaking two trigger words, the listening app sends a text and then calls to an inputted designated phone contact. The Android version works perfectly. The iOs version also works perfectly but the iOs app emiits a PopUp for each, the text and then the call asking "Do you really want to send the text -or- make the call". Basically, I input the contact info and I spoke the trigger words. So, yes I want to send the text and make the call. So, I have to click the two PopUps then the device sends and calls.
Is there a way to suppress the PopUps in any way? The app is designed for emergencies. So, a dely to anser a popup is not at all good.
Maybe by telling the device to allow auto calls and texts from my app?
Any and all help on this issue will be very welcomed...
Thanks :)
Not getting ASCredentialServiceIdentifier in func prepareOneTimeCodeCredentialList(for serviceIdentifiers: [ASCredentialServiceIdentifier]) when trying to use ASCredentialProviderViewController for autofilling one time codes in iOS 18.
We recently transferred two applications to a different account, both of which utilize Keychain and shared app containers. Before transferring the first application, we anticipated losing access to the Keychain and took proactive measures by backing up data to the app’s private container in the final release prior to the transfer.
During the app transfer process, we removed the shared container group ID from the old account and recreated it under the new account. In our testing, Keychain restoration from the local backup was successful, and users experienced no disruptions. However, after releasing the application, we observed that approximately 25% of our users not only lost their Keychain data as expected but also their shared app container data.
As we have been unable to reproduce this issue internally, we are seeking your guidance on how to prevent a similar situation when transferring our second application. At this stage, we have not yet released any updates from the new account, and the Keychain data remains backed up in the app’s private container.
We would appreciate any insights or recommendations you can provide to ensure a smooth transition for our users and make sure we can keep the data in shared container.
Topic:
Privacy & Security
SubTopic:
General
Like many/most developers, I gave Connect the info required to comply with the DSA. Perhaps unlike most, I always give unique email addresses so that I can easily track the source of abuse. Yesterday I finally had a phish come in to my DSA address claiming "Message blocked" and doing the standard click-to-login-for-details FOMO bait.
So, yep, DSA just becomes yet another public database that malicious actors can use to target you.
It would be really nice if Apple provided a way to supply our contact info only for legitimate business purposes. Mail Privacy Protection (or similar) for this would be a start.
I'd like to know:
Let's say there's a backgrounded app which has microphone access, such as Signal or SoundHound or Shazam. It's established that these apps are allowed to record audio in the user's environment even after being backgrounded, seemingly for as long as they want and even upload that sound data.
But can they ALSO continue recording even while another app that is in the foreground is using the microphone, such as the Phone app or Signal?
Topic:
Privacy & Security
SubTopic:
General
Tags:
AudioToolbox
AudioUnit
Core Audio Kit
AVAudioSession
I am working on improving Keychain item storage secured with Face ID using SecAccessControlCreateWithFlags. The implementation uses the .biometryAny flag as shown below:
SecAccessControlCreateWithFlags(
kCFAllocatorDefault,
kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
.biometryAny,
&error
)
While this approach generally works as expected, I encountered a specific edge case during testing. On iOS 18.3.1 with Xcode 15.4, the following sequence causes the Keychain item to become inaccessible:
Navigate to Settings > Face ID & Passcode and select Reset Face ID.
Before setting up a new Face ID, tap the Back button to exit the setup process.
Reopen the Face ID setup and complete the enrollment.
Return to the app—previously stored Keychain items protected by .biometryAny are no longer available.
This behavior appears to be a change introduced in recent iOS versions. In versions prior to iOS 15, resetting or deleting Face ID entries did not invalidate existing Keychain items protected by .biometryAny.
This difference in behavior between iOS versions raises questions about the changes to biometric protection handling.
Any suggestions are welcomed that might shine a light on what the best practice to use keychain access control and prevent the data to become unavailable.
The token is legitimate, however I keep getting bad requests (400). The payload may not be accurate.
No document with the appropriate payload structure is visible to me.
Receipt.bin was tried, but the file content could not be verified.
Referring this URL: https://developer.apple.com/documentation/devicecheck/assessing-fraud-risk
Here is my server side Java code:
private static String sendAttestationWithPayload(String jwt, String keyId,
String attestationData, String clientData) throws Exception {
// Create JSON payload
JSONObject payload = new JSONObject();
payload.put("keyId", keyId);
payload.put("attestationData", attestationData);
payload.put("clientData", clientData);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(APPLE_ATTESTATION_URL))
.header("Authorization", "Bearer " + jwt)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload.toString()))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
handleResponse(response);
return response.body();
}
I have my custom Authplugin implemented at login (system.login.console), and I want to remove password requirement validation/authentication from system.login.console authorization right. Do you see any functionality loss in completely removing password need at login. And is there any reference which can help me here to acheive this?
Hello everyone,
I'm working on a project where I intend to use Secure Enclave-based, device-bound private keys within a Webauthn flow. I have the following question:
Is it possible to generate private keys in the Secure Enclave with integrated attestation in order to reliably prove to a relying party the authenticity and uncompromised state of the key?
If so, I would appreciate details on the implementation—specifically, any prerequisites, limitations, or particular API calls and configuration options that need to be considered.
I look forward to any advice, best practices, or pointers to further documentation on this topic.
Thank you in advance for your support!
Best regards,
Alex
Topic:
Privacy & Security
SubTopic:
General
Tags:
Authentication Services
Passkeys in iCloud Keychain
Hello, I am at wits' end with the Apple Sign-in api. I have tested in stage and it works beautifully, but when i push to production it gives me the error "invalid_client".
I'm confident the setup is correct, when I asked Apple for help over the phone, they sent me a few forums with no answers.
Has anyone had the same issue? How did you resolve?
Could it be because I have two app IDs and two service IDs? (prod + stage)
Help!
Topic:
Privacy & Security
SubTopic:
Sign in with Apple
Tags:
Mobile Core Services
App ID
Sign in with Apple REST API
I'm working on a Password Manager app that integrates with the AutoFill Credential Provider to provide stored passwords and OTPs to the user within Safari and other apps.
Password AutoFill works perfectly.
I'm unable to get iOS to register that the app supports OTPs though.
I've followed the Apple documentation here: https://developer.apple.com/documentation/authenticationservices/providing-one-time-passcodes-to-autofill and added "ProvidesOneTimeCodes" to the AutoFill extension's Info.plist, but iOS just doesn't seem to notice the OTP support.
<key>ASCredentialProviderExtensionCapabilities</key>
<dict>
<key>ProvidesOneTimeCodes</key>
<true/>
<key>ProvidesPasswords</key>
<true/>
</dict>
Any help would be greatly appreicated!
Topic:
Privacy & Security
SubTopic:
General
Tags:
Extensions
Entitlements
Autofill
Authentication Services
We are working with an iOS app where we have enabled the “Generate Debug Symbols” setting to true in Xcode. As a result, the .dSYM files are generated and utilized in Firebase Crashlytics for crash reporting.
However, we received a note in our Vulnerability Assessment report indicating a potential security concern. The report mentions that the .ipa file could be reverse-engineered due to the presence of debug symbols, and that such symbols should not be included in a released app. We could not find any security-related information about this flag, “Generate Debug Symbols,” in Apple’s documentation.
Could you please clarify if enabling the “Generate Debug Symbols” flag in Xcode for a production app creates any security vulnerabilities, such as the one described in the report?
The report mentions the following vulnerability: TEST-0219: Testing for Debugging Symbols
The concern raised is that debugging symbols, while useful for crash symbolication, may be leveraged to reverse-engineer the app and should not be present in a production release.
Your prompt confirmation on this matter would be greatly appreciated. Thank you in advance for your assistance.
Why does the following code generate a public key that can't be parsed by openssl?
import Security
import CryptoKit
func generateKeys() throws -> (privateKey: SecKey, publicKey: SecKey) {
let query: [String: Any] = [
kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom,
kSecAttrKeySizeInBits as String: 256,
kSecAttrIsPermanent as String: false
]
var error: Unmanaged<CFError>?
guard let privateKey = SecKeyCreateRandomKey(query as CFDictionary, &error) else {
throw error!.takeRetainedValue()
}
let publicKey = SecKeyCopyPublicKey(privateKey)!
return (privateKey, publicKey)
}
extension SecKey {
func exportBase64EncodedKey() -> String {
var error: Unmanaged<CFError>?
guard let data = SecKeyCopyExternalRepresentation(self, &error) else {
fatalError("Failed to export key: \(error!.takeRetainedValue())")
}
return (data as Data).base64EncodedString(options: [.lineLength64Characters])
}
}
func printPublicKey() {
let keyPair = try! generateKeys()
let encodedPublicKey = keyPair.publicKey.exportBase64EncodedKey()
var header = "-----BEGIN PUBLIC KEY-----"
var footer = "-----END PUBLIC KEY-----"
var pemKey = "\(header)\n\(encodedPublicKey)\n\(footer)\n"
print(pemKey)
}
printPublicKey()
when parsing the key I get this:
openssl pkey -pubin -in new_public_key.pem -text -noout
Could not find private key of Public Key from new_public_key.pem
404278EC01000000:error:1E08010C:DECODER routines:OSSL_DECODER_from_bio:unsupported:crypto/encode_decode/decoder_lib.c:102:No supported data to decode.
Replacing kSecAttrKeyTypeECSECPrimeRandom with kSecAttrKeyTypeRSA and a bigger key size (e.g. 2048) gives me a working public key that can be parsed by Openssl.
Thanks!
I am implementing Apple Sign-In for a multi-platform application, specifically for the web component using the REST API flow.
I am encountering an invalid_request Invalid web redirect url error when attempting to use a newly registered redirect URL.
Here are the details:
Original Test URL: I initially registered a redirect URL, let's call it [Your Original Test Redirect URL, e.g., https://test.yourdomain.com/auth/callback], for testing purposes. This URL worked correctly.
New Service URL: I then registered a second redirect URL, [Your New Service Redirect URL, e.g., https://www.yourdomain.com/auth/callback], intended for my production service. This URL was registered approximately 5 days ago (including the weekend).
The Problem: The new service URL ([Your New Service Redirect URL]) is still not working and consistently returns the invalid_request Invalid web redirect url error.
Puzzling Behavior: Furthermore, I have since deleted the original test URL ([Your Original Test Redirect URL]) from the Service ID configuration in the Apple Developer portal. However, the deleted test URL still appears to function correctly when I use it.
This situation is highly confusing: The newly registered URL is not working after 5 days, while the URL I have deleted from the configuration is still operational.
The Service ID in question is [Your Service ID, e.g., com.yourdomain.service].
Could you please investigate why the new redirect URL ([Your New Service Redirect URL]) is not becoming active and is returning the invalid_request error, and also explain why the deleted URL ([Your Original Test Redirect URL]) remains functional?
Any guidance or assistance you can provide to resolve this issue with the new URL would be greatly appreciated.
Thank you for your time and support.
Sincerely,
Topic:
Privacy & Security
SubTopic:
Sign in with Apple
Our business model is to identify Frauds using our advanced AI/ML model. However, in order to do so we need to collect many device information which seems to be ok according to https://developer.apple.com/app-store/user-privacy-and-data-use/
But it's also prohibited to generate a fingerprint, so I need more clarification here.
Does it mean I can only use the data to identify that a user if either fraud or not but I cannot generate a fingerprint to identify the device?
If so, I can see many SKD in the market that generates Fingerprints like https://fingerprint.com/blog/local-device-fingerprint-ios/
and https://shield.com/?
Topic:
Privacy & Security
SubTopic:
General
Tags:
Analytics & Reporting
DeviceCheck
Device Activity
Privacy
Hi everyone,
I’m developing a multiplayer iOS game that uses Multipeer Connectivity for local peer-to-peer networking. I’d like to display user-assigned device names in the UI to help players identify each other during the connection process. In iOS 16 and later, accessing UIDevice.current.name requires the User-Assigned Device Name Entitlement.
The documentation states that the entitlement is granted for functionality involving “interaction between multiple devices that the same user operates”. My game is strictly multiplayer, with devices owned by different users, not a single user managing multiple devices.
I have a few questions regarding this:
Does the requirement for “devices operated by the same user” definitively exclude multiplayer scenarios where devices belong to different players? Can a Multipeer Connectivity-based game qualify for the entitlement in this case?
If the entitlement is not applicable, is prompting users to enter custom names the recommended approach for identifying devices in a multiplayer UI?
Has anyone successfully obtained this entitlement for a similar multiplayer use case with Multipeer Connectivity?
Thanks in advance.
Hi! We're having issues with the sign in flow, starting today. As per the documentation, the issuer of the tokens should be https://appleid.apple.com sign in docs.
But in the published configuration, it is now stated as https://account.apple.com metadata endpoint.
Once the token is received through the sign in flow, the issuer is however still appleid.apple.com. This is causing problems for us where we expect the issuer in the metadata endpoint to be the same as the actual token issuer. What is correct here?
Topic:
Privacy & Security
SubTopic:
Sign in with Apple
Hi everyone,
I'm developing a C++ plugin (.bundle) for a third-party host application (Autodesk Maya) on macOS, and I'm finalizing the design for our licensing system. The plugin is distributed outside the Mac App Store.
My goal is to securely store a license key in the user's Keychain. After some research, my proposed implementation is as follows:
On activation, store the license data in the user's login keychain as a Generic Password (kSecClassGenericPassword) using the SecItem APIs.
To ensure the plugin can access the item when loaded by Maya, I will use a specific Keychain Access Group (e.g., MY_TEAM_ID.com.mywebsite).
The final .bundle will be code-signed with our company's Developer ID certificate.
The signature will include an entitlements file (.entitlements) that specifies the matching keychain-access-groups permission.
My understanding is that this combination of a unique Keychain Access Group and a properly signed/entitled bundle is the key to getting reliable Keychain access. This should also correctly trigger the one-time user permission prompt on first use.
Does this sound like the correct and most robust approach for this scenario? Are there any common pitfalls with a plugin's Keychain access from within a host app that I should be aware of?
Thanks for any feedback!
Topic:
Privacy & Security
SubTopic:
General