iOS MDM:iOS MDM和支持MDM的iOS应用程序的常见密钥/ID

3
我正在开发MDM解决方案,遇到了UDID问题。 我们有一个iOS应用程序,是iOS MDM服务器的支持应用程序。在设备完成与我们的MDM服务器的MDM注册后,可以启动此支持应用程序。
在设备注册中,我们可以在服务器端获取设备UDID,并将此设备UDID用作iOS MDM和iOS Supporting应用程序的公共密钥。要在iOS支持应用程序中登录我们的MDM服务器,用户必须提供用户名、密码和我们使用API [[UIDevice currentDevice] uniqueIdentifier] 捕获的UDID,因此需要这三个参数进行身份认证。
然而,苹果在iOS 5.0中废弃了设备UDID,因此无法使用苹果API在iOS应用程序中捕获设备UDID。
现在我们需要一些可用于iOS MDM证书中的公共密钥,以及我们可以在iOS Supporting应用程序中生成的密钥。这样,只有使用MDM服务器注册iOS设备的用户才能在iOS Supporting应用程序中登录。

请查看链接https://radeeccles.com/blog/create-your-own-unique-device-identifier-udid,这可能会有所帮助。 - User97693321
1个回答

3

您可以使用wifi mac地址作为UDID的替代。获取mac地址的逻辑如下,您可以在支持iOS应用程序中使用它来获取mac地址。您可以使用MDM命令在服务器端获取wifi mac地址。

//.h文件

#import <Foundation/Foundation.h>

@interface MacAddress : NSObject

+ (NSString *)getMacAddress;

@end

//实现文件

#import "MacAddress.h"
#import <sys/socket.h>
#import <sys/sysctl.h>
#import <net/if.h>
#import <net/if_dl.h>

@implementation MacAddress

+ (NSString *)getMacAddress
{
  int                 mgmtInfoBase[6];
  char                *msgBuffer = NULL;
  size_t              length;
  unsigned char       macAddress[6];
  struct if_msghdr    *interfaceMsgStruct;
  struct sockaddr_dl  *socketStruct;
  NSString            *errorFlag = NULL;

  // Setup the management Information Base (mib)
  mgmtInfoBase[0] = CTL_NET;        // Request network subsystem
  mgmtInfoBase[1] = AF_ROUTE;       // Routing table info
  mgmtInfoBase[2] = 0;              
  mgmtInfoBase[3] = AF_LINK;        // Request link layer information
  mgmtInfoBase[4] = NET_RT_IFLIST;  // Request all configured interfaces

  // With all configured interfaces requested, get handle index
  if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0) 
    errorFlag = @"if_nametoindex failure";
  else
  {
    // Get the size of the data available (store in len)
    if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0) 
      errorFlag = @"sysctl mgmtInfoBase failure";
    else
    {
      // Alloc memory based on above call
      if ((msgBuffer = malloc(length)) == NULL)
        errorFlag = @"buffer allocation failure";
      else
      {
        // Get system information, store in buffer
        if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0)
          errorFlag = @"sysctl msgBuffer failure";
      }
    }
  }
  // Befor going any further...
  if (errorFlag != NULL)
  {
    NSLog(@"Error: %@", errorFlag);
    return errorFlag;
  }
  // Map msgbuffer to interface message structure
  interfaceMsgStruct = (struct if_msghdr *) msgBuffer;
  // Map to link-level socket structure
  socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);  
  // Copy link layer address data in socket structure to an array
  memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);  
  // Read from char array into a string object, into traditional Mac address format
  NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", 
                                macAddress[0], macAddress[1], macAddress[2], 
                                macAddress[3], macAddress[4], macAddress[5]];
  //NSLog(@"Mac Address: %@", macAddressString);  
  // Release the buffer memory
  free(msgBuffer);
  return macAddressString;
}

@end

我们使用MAC地址以及产品名称来增加一些额外的保证,以便我们能够识别设备。 - rlandster

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接