本文简要介绍ruby语言中 OpenSSL::Netscape::SPKI类
的用法。
一个简单的公钥基础设施实现(发音为“spooky”)。结构定义为
PublicKeyAndChallenge ::= SEQUENCE { spki SubjectPublicKeyInfo, challenge IA5STRING } SignedPublicKeyAndChallenge ::= SEQUENCE { publicKeyAndChallenge PublicKeyAndChallenge, signatureAlgorithm AlgorithmIdentifier, signature BIT STRING }
其中SubjectPublicKeyInfo和AlgorithmIdentifier的定义可以在RFC5280中找到。 SPKI
通常在浏览器中使用 HTML
例子
创建 SPKI
key = OpenSSL::PKey::RSA.new 2048
spki = OpenSSL::Netscape::SPKI.new
spki.challenge = "RandomChallenge"
spki.public_key = key.public_key
spki.sign(key, OpenSSL::Digest.new('SHA256'))
#send a request containing this to a server generating a certificate
验证 SPKI
请求
request = #...
spki = OpenSSL::Netscape::SPKI.new request
unless spki.verify(spki.public_key)
# signature is invalid
end
#proceed
相关用法
- Ruby Symbol capitalize用法及代码示例
- Ruby SizedQueue clear()用法及代码示例
- Ruby Spotter.spot_op_asgn2_for_name用法及代码示例
- Ruby StringScanner skip_until用法及代码示例
- Ruby StringScanner search_full用法及代码示例
- Ruby String.match?用法及代码示例
- Ruby StringScanner.beginning_of_line?用法及代码示例
- Ruby Stat.stat <=>用法及代码示例
- Ruby Symbol.to_proc用法及代码示例
- Ruby Symbol.end_with?用法及代码示例
- Ruby StringScanner restsize用法及代码示例
- Ruby Spotter.spot_opcall_for_name用法及代码示例
- Ruby Set flatten()用法及代码示例
- Ruby SpecificationProvider.requirement_satisfied_by?用法及代码示例
- Ruby Set.replace用法及代码示例
- Ruby String delete!用法及代码示例
- Ruby String chop!用法及代码示例
- Ruby SizedQueue push()用法及代码示例
- Ruby Specification.file_name用法及代码示例
- Ruby SimpleDelegator.__setobj__用法及代码示例
- Ruby String.unpack用法及代码示例
- Ruby Stat.world_writable?用法及代码示例
- Ruby String each_line用法及代码示例
- Ruby StringScanner.pos=用法及代码示例
- Ruby StringScanner check_until用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 SPKI类。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。