我有一个数字证书(扩展名为.crt),例如:
dates = MyModel.pluck("distinct date(datetime_column)")
dates.group_by(&:year).map do |y, items|
[y, items.group_by(&:month).map { |m, days| [m, days.map(&:day)] }.to_h]
end.to_h
我的问题是如何在不知道任何其他内容的情况下从中提取公钥的素数?我找不到任何在线转换器结构来解决它。
答案 0 :(得分:0)
事实证明,该文件实际上是EC密钥的$ openssl asn1parse -in test.pem -i -dump
0:d=0 hl=3 l= 146 cons: SEQUENCE
3:d=1 hl=2 l= 1 prim: INTEGER :01
6:d=1 hl=2 l= 40 cons: SEQUENCE
8:d=2 hl=2 l= 7 prim: OBJECT :prime-field
17:d=2 hl=2 l= 29 prim: INTEGER :FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D
48:d=1 hl=2 l= 6 cons: SEQUENCE
50:d=2 hl=2 l= 1 prim: OCTET STRING
0001 - <SPACES/NULS>
53:d=2 hl=2 l= 1 prim: OCTET STRING
0000 - 05 .
56:d=1 hl=2 l= 57 prim: OCTET STRING
0000 - 04 a1 45 5b 33 4d f0 99-df 30 fc 28 a1 69 a4 67 ..E[3M...0.(.i.g
0010 - e9 e4 70 75 a9 0f 7e 65-0e b6 b7 a4 5c 7e 08 9f ..pu..~e....\~..
0020 - ed 7f ba 34 42 82 ca fb-d6 f7 e3 19 f7 c0 b0 bd ...4B...........
0030 - 59 e2 ca 4b db 55 6d 61-a5 Y..K.Uma.
115:d=1 hl=2 l= 29 prim: INTEGER :010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7
146:d=1 hl=2 l= 1 prim: INTEGER :01
块,而不是证书。我通过转储ASN.1结构并将其与我生成的另一个EC密钥进行比较来发现这一点。
$ openssl ecparam -in test.pem -text
Field Type: prime-field
Prime:
00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ff:ff:e5:6d
A: 0
B: 5 (0x5)
Generator (uncompressed):
04:a1:45:5b:33:4d:f0:99:df:30:fc:28:a1:69:a4:
67:e9:e4:70:75:a9:0f:7e:65:0e:b6:b7:a4:5c:7e:
08:9f:ed:7f:ba:34:42:82:ca:fb:d6:f7:e3:19:f7:
c0:b0:bd:59:e2:ca:4b:db:55:6d:61:a5
Order:
01:00:00:00:00:00:00:00:00:00:00:00:00:00:01:
dc:e8:d2:ec:61:84:ca:f0:a9:71:76:9f:b1:f7
Cofactor: 1 (0x1)
-----BEGIN EC PARAMETERS-----
MIGSAgEBMCgGByqGSM49AQECHQD///////////////////////////////7//+Vt
MAYEAQAEAQUEOQShRVszTfCZ3zD8KKFppGfp5HB1qQ9+ZQ62t6Rcfgif7X+6NEKC
yvvW9+MZ98CwvVniykvbVW1hpQIdAQAAAAAAAAAAAAAAAAAB3OjS7GGEyvCpcXaf
sfcCAQE=
-----END EC PARAMETERS-----
修复标题允许您像这样读取文件:
BEGIN EC PARAMETERS
这是以前输出的格式更加精美的版本。请注意正确的BEGIN CERTIFICATE
而不是override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
}
标头。主要块显示在上面的输出中。