मैं अभी मोबाइल पर एक ऑनसाइट से वापस आया जो मोबाइलइरॉन का उपयोग कर रहा था और बस ऐसा करने के लिए देख रहा था। मोबाइलइरॉन डेवलपमेंट सपोर्ट ने हमें कोड के इस स्निपेट के साथ प्रदान किया, जो ऐपकनेक्ट रैपर द्वारा मोबाइलआईरॉन कोर कॉन्फ टेक्नोलॉजी के माध्यम से प्रदान किया गया प्रमाणपत्र आयात करता है।
यह सुंदर नहीं है, लेकिन जैसा कि यह उनके द्वारा प्रदान किया गया था, मुझे इसे संशोधित करने की अनुमति नहीं थी। हालांकि यह काम करता है! अपने AppDelegate.m में
- (NSString *)appConnectConfigChangedTo:(NSDictionary *)newConfig;
और यह, सही aforemention pragma चिह्न के बाद:: आप अपने AppDelegate.h में इस डालने
#pragma mark UIApplicationDelegate implementation
- (NSString *)appConnectConfigChangedTo:(NSDictionary *)newConfig{
//NSLog(@"New config: %@", newConfig); //unsecure
NSLog(@"New config retrieved"); //confirm we got a new config
NSString *certStr = [newConfig valueForKey:@"kUserCert"]; //Store certificate as String
NSString *certPassword = [newConfig valueForKey:@"kUserCert_MI_CERT_PW"]; //Store certificate password as string
NSData *cert = [[NSData alloc] initWithBase64EncodedString:certStr options:0]; //only for iOS7+, decodes base64 encoded certificate
CFDataRef pkcs12Data = (__bridge CFDataRef)cert; //Extract identity & certificate objects from
CFStringRef password = (__bridge CFStringRef)certPassword; //the cert data Identity
SecIdentityRef myIdentity = nil; //Initialize variable for identity
SecCertificateRef myCertificate = nil; //Initialize variable for certificate
OSStatus status = extractIdentityAndTrust(pkcs12Data, password, &myIdentity, nil); //Use Apple-provided method for extracting Identity and Trust
if (status != errSecSuccess || myIdentity == nil) { NSLog(@"Failed to extract identity and trust: %ld", status);} //Likely due to corruption
else { SecIdentityCopyCertificate(myIdentity, &myCertificate); } //This method is supposed to store the Certificate, but Fiori doesn't see it here
const void *certs[] = { myCertificate }; //Initialize an array for one certificate
CFArrayRef certsArray = CFArrayCreate(NULL, certs, 1, NULL); //Make the array the way Apple wants it to be
NSURLCredential *credential = [NSURLCredential credentialWithIdentity:myIdentity certificates:(__bridge NSArray*)certsArray persistence:NSURLCredentialPersistencePermanent]; //MobileIron's method of Credential storage
NSMutableDictionary *secIdentityParams = [[NSMutableDictionary alloc] init]; //Initialize Dictionary to store identity
[secIdentityParams setObject:(__bridge id)myIdentity forKey:(__bridge id)kSecValueRef]; //Build the secIdentityParams dictionary in the way the next method expects it to be
OSStatus certInstallStatus = SecItemAdd((__bridge CFDictionaryRef) secIdentityParams, NULL); //Add the identity to the keychain for Fiori consumption
if (myIdentity) CFRelease(myIdentity); //Free
if (certsArray) CFRelease(certsArray); //Up
if (myCertificate) CFRelease(myCertificate); //Memory
return nil; //Success
}
// Copied from Apple document on Certificates:
// http://developer.apple.com/library/mac/documentation/security/conceptual/CertKeyTrustProgGuide/CertKeyTrustProgGuide.pdf
OSStatus extractIdentityAndTrust(CFDataRef inP12data, CFStringRef password, SecIdentityRef *identity, SecTrustRef *trust){
OSStatus securityError = errSecSuccess;
const void *keys[] = { kSecImportExportPassphrase };
const void *values[] = { password };
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL);
CFArrayRef items = nil;
securityError = SecPKCS12Import(inP12data, options, &items);
if (securityError == errSecSuccess) {
CFDictionaryRef myIdentityAndTrust = CFArrayGetValueAtIndex(items, 0);
if (identity && CFDictionaryGetValueIfPresent(myIdentityAndTrust, kSecImportItemIdentity, (const void **)identity)) {
CFRetain(*identity);
}
if (trust && CFDictionaryGetValueIfPresent(myIdentityAndTrust, kSecImportItemTrust, (const void **)trust)) {
CFRetain(*trust);
}
}
if (options) {CFRelease(options);}
if (items) {CFRelease(items);}
return securityError;
}
आपके द्वारा अपने ऐप का निर्माण किया है, MobileIron व्यवस्थापक से संपर्क ऐप को 'लपेटें' ताकि वह ऐपकनेक्ट का उपयोग कर सके। एक बार ऐसा करने के बाद और मोबाइल आईरॉन के माध्यम से उपयोगकर्ताओं को परीक्षण करने के लिए लपेटा गया ऐप तैनात किया जाता है, एक कोर कॉन्फ़िगर सेट करें जो प्रावधान किए गए उपयोगकर्ता के लिए उपयोगकर्ता प्रमाणपत्र विशिष्ट लेता है और इसे कोर कॉन्फ़िगर कुंजी "kUserCert" के अंतर्गत प्रावधान डिवाइस पर धक्का देता है।
बहुत रोचक। इसे आज़माने के लिए मोबाइलइरॉन की एक प्रति पर अपना हाथ लेने की कोशिश करनी होगी। –
क्या आपको मोबाइलइरॉन एसडीके के साथ एकीकृत करने की आवश्यकता है? – windfly2006
इस कार्यक्षमता के लिए कोई पारंपरिक लाइब्रेरी या एसडीके नहीं था: मोबाइलइरॉन ने हमें नमूना कोड प्रदान किया, और ऐप को कनेक्ट करने के लिए ऐप को लपेटने के लिए हमें अपने रैपर एप्लिकेशन का उपयोग करना पड़ा। –