fast-client-cert 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +1 -1
- data/lib/fast/client_cert/cert.rb +2 -2
- data/lib/fast/client_cert/chain.rb +23 -7
- data/lib/fast/client_cert/pem.rb +10 -7
- data/lib/fast/client_cert/version.rb +1 -1
- data/lib/fast/client_cert.rb +19 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a9616145c03677b955c1cf9105a07a323c0887f9f03808d1ce058bdeffb2ca9
|
|
4
|
+
data.tar.gz: 9aed1ac3ed3bc2f66c133a7f5ae7b3b3c1b21251602aba1c6d07e72368ffa0b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f6ebba578f44e421fabd3cc38229579116661377ed6ed04f931a45426f09f7fce921ea83ede3a353be2cd1161de851184d731791708191111f49cb8819e2586
|
|
7
|
+
data.tar.gz: f819a009b1da634ead14359d3bd0e0f1b60db51b8d81dd2eaa731b966a6ae3aab6801195e6ea6771acc3685ab9e0aebe6ab9ad99bccf26bb94bf859d2b195cfe
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.2 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
- Fixed: the PEM block guard refuses a payload region of blank lines
|
|
6
|
+
alone — Error, "the PEM block carries no payload", instead of
|
|
7
|
+
emitting the empty Byte Sequence `::` — a DER-encoded X.509
|
|
8
|
+
certificate is never zero bytes (§2.1), the same refusal the empty
|
|
9
|
+
Byte Sequence gets at the shared Checks seam since 0.1.1.
|
|
10
|
+
- Fixed: the parse, construction and emit boundaries never send a
|
|
11
|
+
message into the value they are checking — the shared Checks seam
|
|
12
|
+
(`byte_sequence?`, and what a constraint error shows of the
|
|
13
|
+
offender: its class, or the placeholder "a classless object" —
|
|
14
|
+
never the value's own `inspect`), both constructions, and
|
|
15
|
+
`Chain#split`'s per_line guard read the value with the
|
|
16
|
+
never-dispatch forms (`case value when Klass`, `Module#===`), so a
|
|
17
|
+
classless value (a `BasicObject` descendant) at a boundary raises
|
|
18
|
+
the documented error class instead of escaping the error contract
|
|
19
|
+
as a raw `NoMethodError`.
|
|
20
|
+
- Fixed: requirement messages lead with the requirement — "the value
|
|
21
|
+
must be a Byte Sequence, received …", "a member must be a Byte
|
|
22
|
+
Sequence, received …", "per_line must be a positive Integer,
|
|
23
|
+
received …" — so no message reads as if the received value were
|
|
24
|
+
the required one.
|
|
25
|
+
|
|
3
26
|
## 0.1.1 (2026-11-27)
|
|
4
27
|
|
|
5
28
|
- Fixed: the strict `parse!` positions member errors through the
|
data/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Fast::ClientCert::Cert.valid?("!!") # => false
|
|
|
56
56
|
begin
|
|
57
57
|
Fast::ClientCert::Cert.parse!("5")
|
|
58
58
|
rescue Fast::ClientCert::ParseError => e
|
|
59
|
-
e.message # => "Client-Cert: the value
|
|
59
|
+
e.message # => "Client-Cert: the value must be a Byte Sequence, received Integer"
|
|
60
60
|
e.offset # => 0
|
|
61
61
|
end
|
|
62
62
|
```
|
|
@@ -55,7 +55,7 @@ module Fast
|
|
|
55
55
|
return from_item(item) if Checks.byte_sequence?(item.value)
|
|
56
56
|
|
|
57
57
|
raise ParseError.new(
|
|
58
|
-
"Client-Cert: the value
|
|
58
|
+
"Client-Cert: the value must be a Byte Sequence, received #{Checks.shown(item)}", value_offset(input)
|
|
59
59
|
)
|
|
60
60
|
rescue SFV::ParseError => e
|
|
61
61
|
raise ParseError.new(e.message, e.offset)
|
|
@@ -111,7 +111,7 @@ module Fast
|
|
|
111
111
|
# SerializeError before anything is emitted.
|
|
112
112
|
def initialize(der)
|
|
113
113
|
unless Checks.byte_sequence?(der)
|
|
114
|
-
raise SerializeError.new("Client-Cert: the value
|
|
114
|
+
raise SerializeError.new("Client-Cert: the value must be a Byte Sequence, received #{Checks.shown(der)}", 0)
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
hold(SFV::Item.new(der.freeze, EMPTY_PARAMS))
|
|
@@ -73,7 +73,7 @@ module Fast
|
|
|
73
73
|
member = members[index]
|
|
74
74
|
unless member_ok?(member)
|
|
75
75
|
raise ParseError.new(
|
|
76
|
-
"a Client-Cert-Chain member
|
|
76
|
+
"a Client-Cert-Chain member must be a Byte Sequence, received #{Checks.shown(member)}",
|
|
77
77
|
member_offset(input, index)
|
|
78
78
|
)
|
|
79
79
|
end
|
|
@@ -144,14 +144,19 @@ module Fast
|
|
|
144
144
|
# Anything else raises SerializeError before anything is
|
|
145
145
|
# emitted.
|
|
146
146
|
def initialize(ders)
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
case ders
|
|
148
|
+
when Array
|
|
149
|
+
nil
|
|
150
|
+
else
|
|
151
|
+
raise SerializeError.new("Client-Cert-Chain members must be an Array, received #{shape(ders)}", 0)
|
|
149
152
|
end
|
|
150
153
|
|
|
151
154
|
items = []
|
|
152
155
|
ders.each do |der|
|
|
153
156
|
unless Checks.byte_sequence?(der)
|
|
154
|
-
raise SerializeError.new(
|
|
157
|
+
raise SerializeError.new(
|
|
158
|
+
"a Client-Cert-Chain member must be a Byte Sequence, received #{Checks.shown(der)}", 0
|
|
159
|
+
)
|
|
155
160
|
end
|
|
156
161
|
|
|
157
162
|
items << Item.new(der.freeze, EMPTY_PARAMS)
|
|
@@ -202,9 +207,13 @@ module Fast
|
|
|
202
207
|
# a caller bug — ArgumentError, never a field error. The empty
|
|
203
208
|
# chain answers no lines.
|
|
204
209
|
def split(per_line)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
210
|
+
valid = case per_line
|
|
211
|
+
when Integer
|
|
212
|
+
per_line.positive?
|
|
213
|
+
else
|
|
214
|
+
false
|
|
215
|
+
end
|
|
216
|
+
raise ArgumentError, "per_line must be a positive Integer, received #{shape(per_line)}" unless valid
|
|
208
217
|
|
|
209
218
|
lines = []
|
|
210
219
|
index = 0
|
|
@@ -236,6 +245,13 @@ module Fast
|
|
|
236
245
|
|
|
237
246
|
private
|
|
238
247
|
|
|
248
|
+
# The class of a value an error message names, or a placeholder
|
|
249
|
+
# when the value has none (a BasicObject descendant) — the
|
|
250
|
+
# message never calls a method on the value it is rejecting.
|
|
251
|
+
def shape(value)
|
|
252
|
+
defined?(value.class) ? value.class : "a classless object"
|
|
253
|
+
end
|
|
254
|
+
|
|
239
255
|
# The one place the held state is written, then frozen: the
|
|
240
256
|
# members as parsed (or as built), and the DERs view derived
|
|
241
257
|
# from them.
|
data/lib/fast/client_cert/pem.rb
CHANGED
|
@@ -34,12 +34,13 @@ module Fast
|
|
|
34
34
|
# payload line stripped of the whitespace around it, generous the
|
|
35
35
|
# way textual encodings need. Blank lines may lead and follow the
|
|
36
36
|
# block; CRLF line endings are tolerated. Armor-shape failures
|
|
37
|
-
# raise Error: no BEGIN line, the END missing, no payload
|
|
37
|
+
# raise Error: no BEGIN line, the END missing, no payload (a
|
|
38
|
+
# payload region of blank lines alone carries no payload), or
|
|
38
39
|
# content other than blank lines after the END (a second block —
|
|
39
40
|
# one PEM block at a time; pass an Array of blocks to
|
|
40
41
|
# pems_to_field for a chain). TypeError for a non-String.
|
|
41
42
|
def pem_to_field(pem)
|
|
42
|
-
raise TypeError, "a PEM block
|
|
43
|
+
raise TypeError, "a PEM block must be a String, received #{pem.class}" unless pem.is_a?(String)
|
|
43
44
|
|
|
44
45
|
lines = pem.split("\n", -1)
|
|
45
46
|
first = 0
|
|
@@ -54,9 +55,11 @@ module Fast
|
|
|
54
55
|
unless first_armor_line(lines, first, last) == last
|
|
55
56
|
raise Error, "one PEM block at a time — pass an Array of blocks for a chain"
|
|
56
57
|
end
|
|
57
|
-
raise Error, "the PEM block carries no payload" unless last - first > 1
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
base64 = lines[first + 1...last].map(&:strip).join
|
|
60
|
+
raise Error, "the PEM block carries no payload" if base64.empty?
|
|
61
|
+
|
|
62
|
+
":#{base64}:"
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
# The inverse: ":<base64>:" → one RFC 7468 block — the base64
|
|
@@ -66,7 +69,7 @@ module Fast
|
|
|
66
69
|
# interior, or Error is raised before anything is written.
|
|
67
70
|
# TypeError for a non-String.
|
|
68
71
|
def field_to_pem(field)
|
|
69
|
-
raise TypeError, "a field value
|
|
72
|
+
raise TypeError, "a field value must be a String, received #{field.class}" unless field.is_a?(String)
|
|
70
73
|
|
|
71
74
|
base64 = base64_interior(field)
|
|
72
75
|
block = "#{BEGIN_ARMOR}\n"
|
|
@@ -86,7 +89,7 @@ module Fast
|
|
|
86
89
|
# ", " separator. The empty Array raises Error — nothing to
|
|
87
90
|
# convert. TypeError for a non-Array.
|
|
88
91
|
def pems_to_field(blocks)
|
|
89
|
-
raise TypeError, "blocks
|
|
92
|
+
raise TypeError, "blocks must be an Array of PEM Strings, received #{blocks.class}" unless blocks.is_a?(Array)
|
|
90
93
|
raise Error, "nothing to convert — the blocks Array is empty" if blocks.empty?
|
|
91
94
|
|
|
92
95
|
blocks.map { |block| pem_to_field(block) }.join(", ")
|
|
@@ -104,7 +107,7 @@ module Fast
|
|
|
104
107
|
# base Error carrying the region scan's own message. The empty
|
|
105
108
|
# value answers no blocks. TypeError for a non-String.
|
|
106
109
|
def field_to_pems(field)
|
|
107
|
-
raise TypeError, "a field value
|
|
110
|
+
raise TypeError, "a field value must be a String, received #{field.class}" unless field.is_a?(String)
|
|
108
111
|
return [].freeze if field.empty?
|
|
109
112
|
|
|
110
113
|
regions = SFV.regions_list(field)
|
data/lib/fast/client_cert.rb
CHANGED
|
@@ -76,16 +76,29 @@ module Fast
|
|
|
76
76
|
# boundary reads: both strict parses, both constructions, and
|
|
77
77
|
# both fail-closed falls.
|
|
78
78
|
def byte_sequence?(value)
|
|
79
|
-
|
|
79
|
+
case value
|
|
80
|
+
when SFV::Token
|
|
81
|
+
false
|
|
82
|
+
when String
|
|
83
|
+
value.encoding == BINARY && !value.empty?
|
|
84
|
+
else
|
|
85
|
+
false
|
|
86
|
+
end
|
|
80
87
|
end
|
|
81
88
|
|
|
82
89
|
# What a constraint error shows of the offender: the value's
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
#
|
|
90
|
+
# class — never a method call into the value, which a classless
|
|
91
|
+
# object (a BasicObject descendant) would refuse — or the
|
|
92
|
+
# placeholder when it has none. An Item is unwrapped first (an
|
|
93
|
+
# inner list shows its own class, Fast::SFV::InnerList).
|
|
86
94
|
def shown(shape)
|
|
87
|
-
value =
|
|
88
|
-
|
|
95
|
+
value = case shape
|
|
96
|
+
when SFV::Item
|
|
97
|
+
shape.value
|
|
98
|
+
else
|
|
99
|
+
shape
|
|
100
|
+
end
|
|
101
|
+
defined?(value.class) ? value.class : "a classless object"
|
|
89
102
|
end
|
|
90
103
|
end
|
|
91
104
|
private_constant :Checks
|