检查iOS上是否安装了mobileconfig配置文件

检查iOS上是否安装了mobileconfig配置文件

本文介绍了检查iOS上是否安装了mobileconfig配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过以下方式安装mobileconfig文件(在iPhone桌面上在iPhone上以编程方式安装配置文件).

如何检查此配置文件是否已安装?

在iPhone Settings->General->provision file中,我可以找到列表.

解决方案

我发现了以下方法来识别(是否安装了 mobile config ),但是到目前为止,我还没有测试.

步骤:

  • 创建一个自签名根CA ,您可以在终端中使用证书助手 openssl 来完成.

  • 创建另一个证书 并使用自签名根CA

  • 对其进行签名
  • 将在上一步中创建的签名证书附加到xcode

  • 附加自签名根CA 作为移动配置

    的一部分
    • 在IPCU中打开您的移动配置

    • 向下滚动到凭据

    • 按右侧的 Configure

    • 选择自签名根CA (确保其为.cer格式)

    • 立即导出移动配置,然后使用全球受信任的CA 进行签名(例如GoDaddy).如果此步骤完成,则该步骤是可选的,设备将显示移动配置为 verified ,否则在安装移动配置时会显示为 unverified .


代码段:

-(BOOL)IsMobileConfigInstalled {

NSString* certPath = [[NSBundle mainBundle] pathForResource:@"LeafCertificate" ofType:@"cer"];

NSData* certData = [NSData dataWithContentsOfFile:certPath];

SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef) certData);

SecPolicyRef policy = SecPolicyCreateBasicX509();

SecTrustRef trust;

OSStatus err = SecTrustCreateWithCertificates((__bridge CFArrayRef) [NSArray arrayWithObject:(__bridge id)cert], policy, &trust);

SecTrustResultType trustResult = -1;

err = SecTrustEvaluate(trust, &trustResult);

CFRelease(trust);

CFRelease(policy);

CFRelease(cert);

if(trustResult == kSecTrustResultUnspecified)
    return YES;
else
    return NO;
}


参考:

以下是链接,以围绕苹果开发者论坛中的主题

这是指向博客文章的链接. /p>

以下是有关此主题的堆栈溢出讨论的链接 Ref1

Install mobileconfig file through(Installing a configuration profile on iPhone - programmatically) on iPhone Desktop.

How to check whether this config file is installed?

In iPhone Settings->General->provision file,I can find the list.

解决方案

I came across a the following approach to identify if the mobile config is installed or not,But I have not tested though so far.

Steps:

  • Create a Self Signed Root CA you can do it either using Certificate Assistant or openssl in terminal.

  • Create another Certificate and get it Signed using the Self Signed Root CA

  • Attach the Signed Certificate that is created in previous step to the xcode

  • Attach the Self Signed Root CA as a part of the Mobile Config

    • Open your mobile config in the IPCU

    • Scroll down to Credentials

    • Press Configure on the right side

    • Select the Self Signed Root CA (make sure its in .cer format)

    • Export the Mobile Config now and signing it using Globally Trusted CA like GoDaddy.This step is optional if its is done the device will show the mobile config as verified or else it will show as unverified while installing mobile config.


Code Snippet:

-(BOOL)IsMobileConfigInstalled {

NSString* certPath = [[NSBundle mainBundle] pathForResource:@"LeafCertificate" ofType:@"cer"];

NSData* certData = [NSData dataWithContentsOfFile:certPath];

SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef) certData);

SecPolicyRef policy = SecPolicyCreateBasicX509();

SecTrustRef trust;

OSStatus err = SecTrustCreateWithCertificates((__bridge CFArrayRef) [NSArray arrayWithObject:(__bridge id)cert], policy, &trust);

SecTrustResultType trustResult = -1;

err = SecTrustEvaluate(trust, &trustResult);

CFRelease(trust);

CFRelease(policy);

CFRelease(cert);

if(trustResult == kSecTrustResultUnspecified)
    return YES;
else
    return NO;
}


References:

Here is the link to a technical discussion around the topic in apple developer forum

Here is the link to a blog post that takes you step by step.

Here are the links to stack overflow discussions about this topic Ref1, Ref22

这篇关于检查iOS上是否安装了mobileconfig配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 08:23