我正在尝试为我的应用程序实现一个简单的许可证密钥方案,而且我遇到了很大的障碍.我在OpenSSL上关注许可证密钥的示例.
由于该博客文章是在2004年编写的,而OpenSSL已在OS X上弃用,我试图使用安全转换API来完成许可证密钥验证而不是OpenSSL.但是,我正在使用OpenSSL生成私钥和公钥; 许可证密钥是由Ruby Web应用程序使用私钥生成的,使用来自购买者电子邮件地址的SHA-256摘要的Ruby OpenSSL包装程序库.
问题是,我所做的任何事情似乎都不会使用OpenSSL从Ruby生成签名,而安全转换API将验证该签名.
我正在处理的Ruby代码是:
require('openssl')
# The email address used as the content of the license key.
license = 'test@example.com'
# Generate the public/private keypair.
`openssl genrsa -out private_key.pem 2048`
`openssl rsa -in conductor.pem -out public_key.data -pubout`
# Get the private key and a hash of the license.
private_key = OpenSSL::PKey::RSA.new(File.read('private_key.pem'))
signature = OpenSSL::Digest::SHA256.digest(license)
# The signature passed to SecVerifyTransformCreate in the OS X app. I'm not sure which of these SecVerifyTransformCreate is expecting …Run Code Online (Sandbox Code Playgroud)