ppgjx 发表于 2022-4-13 23:06

ruby请教

#!/usr/bin/ruby -w
# -*- coding: UTF-8 -*-
require 'openssl'
passcode_payload ={
'PayloadUUID' => 'RANDOM_STRING_UUID',
'PayloadOrganization' => 'PayloadOrganization',
'PayloadVersion' => 1,
'PayloadIdentifier' => 'com.test.PayloadIdentifier',
'PayloadType' => 'Configuration',
'PayloadDisplayName' => 'PayloadDisplayName',
'PayloadRemovalDisallowed' => false
}
passcode_payload_content = {
'PayloadDescription' => 'PayloadDescription',
'PayloadDisplayName' => 'PayloadDisplayName',
'PayloadIdentifier' => 'PayloadIdentifier',
'PayloadOrganization' => 'PayloadOrganization',
'PayloadType' => 'com.apple.mobiledevice.passwordpolicy',
'PayloadUUID' => "RANDOM_STRING_UUID",
'PayloadVersion' => 1,
'allowSimple' => true,
'forcePIN' => true,
'maxPINAgeInDays' => 20,
'minComplexChars' => 1,
'minLength' => 4,
'requireAlphanumeric' => true
}

passcode_payload_content_array = [passcode_payload_content]

puts passcode_payload_content_array

to_be_encrypted_plist = passcode_payload_content_array.to_plist
device_certificate = OpenSSL::X509::Certificate.new File.read('1.pem')


encrypted_payload = OpenSSL::PKCS7.encrypt([device_certificate],to_be_encrypted_plist, OpenSSL::Cipher::Cipher::new("des-ede3-cbc"),OpenSSL::PKCS7::BINARY)


passcode_payload['EncryptedPayloadContent'] = StringIO.new(encrypted_payload.to_der)

他提示在这passcode_payload_content_array.to_plist   to_plist 方法不存在怎么办呢?

zhangting2022 发表于 2022-4-14 04:57

看不懂,555
页: [1]
查看完整版本: ruby请教