tttls1.3 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b99157535ca4f2b06f4fc6d374116fbc6e496a7807184c56b31be11852d6e5f
4
- data.tar.gz: 33ff8b94d80529bcabd7c4b3d8fe5ea9ee6513d1d90f4efe307f4edf7bbfb1ac
3
+ metadata.gz: 26abf6610ea39c5b35e874bab7e1226afee77c3209dd2ddde497d731bb6fc64b
4
+ data.tar.gz: 13a8a522e126dc29993f6bfef96a59556f043910541decf7224c15db84cfb28d
5
5
  SHA512:
6
- metadata.gz: 29f4cd4e505e33ef0b6f03265a3ecdc8e988a32a965a9079b8c92ee57e50a6ad7e7864fb24d07a14b0ec956fce6ce1c85d9d8072e908e202393c1bd73ad54c1f
7
- data.tar.gz: c5ed00504bbdb7ee0b051a3534ab2c51bbfdbadbd703ca761fb06367b85798217b04ba7b7d1a8003aeff756d3e9b8e7b6f7c375872250de4139e7400760608d4
6
+ metadata.gz: 879a7c9be73deec93e4eff0ee0a0339c2464ad6c4139d5c8da4ad8da06cf8fcdf9bbd6ecef6baeda2f35483d88c91b61deaed17e7ca7a2d25cc105f339d242ce
7
+ data.tar.gz: 44ad60dff635a9ac7a980605ab736f52b67b94d806fa186e86ff022ff82bc712abf9ce215714052787188b35617e1f527534115d6fbb2cc880d5b32dce9df591
@@ -7,7 +7,10 @@ hostname, port = (ARGV[0] || 'localhost:4433').split(':')
7
7
  req = simple_http_request(hostname)
8
8
 
9
9
  socket = TCPSocket.new(hostname, port)
10
- settings = { ca_file: __dir__ + '/../tmp/ca.crt' }
10
+ settings = {
11
+ ca_file: __dir__ + '/../tmp/ca.crt',
12
+ alpn: ['http/1.1', 'http/1.0']
13
+ }
11
14
  client = TTTLS13::Client.new(socket, hostname, settings)
12
15
  client.connect
13
16
  client.write(req)
@@ -7,7 +7,8 @@ hostname, port = (ARGV[0] || 'localhost:4433').split(':')
7
7
  req = simple_http_request(hostname)
8
8
 
9
9
  settings_2nd = {
10
- ca_file: __dir__ + '/../tmp/ca.crt'
10
+ ca_file: __dir__ + '/../tmp/ca.crt',
11
+ alpn: ['http/1.1', 'http/1.0']
11
12
  }
12
13
  process_new_session_ticket = proc do |nst, rms, cs|
13
14
  return if Time.now.to_i - nst.timestamp > nst.ticket_lifetime
@@ -21,6 +22,7 @@ process_new_session_ticket = proc do |nst, rms, cs|
21
22
  end
22
23
  settings_1st = {
23
24
  ca_file: __dir__ + '/../tmp/ca.crt',
25
+ alpn: ['http/1.1', 'http/1.0'],
24
26
  process_new_session_ticket: process_new_session_ticket
25
27
  }
26
28
 
@@ -9,7 +9,8 @@ req = simple_http_request(hostname)
9
9
  socket = TCPSocket.new(hostname, port)
10
10
  settings = {
11
11
  ca_file: __dir__ + '/../tmp/ca.crt',
12
- key_share_groups: [] # empty KeyShareClientHello.client_shares
12
+ key_share_groups: [], # empty KeyShareClientHello.client_shares
13
+ alpn: ['http/1.1', 'http/1.0']
13
14
  }
14
15
  client = TTTLS13::Client.new(socket, hostname, settings)
15
16
  client.connect
@@ -7,7 +7,8 @@ hostname, port = (ARGV[0] || 'localhost:4433').split(':')
7
7
  req = simple_http_request(hostname)
8
8
 
9
9
  settings_2nd = {
10
- ca_file: __dir__ + '/../tmp/ca.crt'
10
+ ca_file: __dir__ + '/../tmp/ca.crt',
11
+ alpn: ['http/1.1', 'http/1.0']
11
12
  }
12
13
  process_new_session_ticket = proc do |nst, rms, cs|
13
14
  return if Time.now.to_i - nst.timestamp > nst.ticket_lifetime
@@ -22,6 +23,7 @@ process_new_session_ticket = proc do |nst, rms, cs|
22
23
  end
23
24
  settings_1st = {
24
25
  ca_file: __dir__ + '/../tmp/ca.crt',
26
+ alpn: ['http/1.1', 'http/1.0'],
25
27
  process_new_session_ticket: process_new_session_ticket
26
28
  }
27
29
 
@@ -7,7 +7,8 @@ hostname, port = (ARGV[0] || 'localhost:4433').split(':')
7
7
  req = simple_http_request(hostname)
8
8
 
9
9
  settings_2nd = {
10
- ca_file: __dir__ + '/../tmp/ca.crt'
10
+ ca_file: __dir__ + '/../tmp/ca.crt',
11
+ alpn: ['http/1.1', 'http/1.0']
11
12
  }
12
13
  process_new_session_ticket = proc do |nst, rms, cs|
13
14
  return if Time.now.to_i - nst.timestamp > nst.ticket_lifetime
@@ -21,6 +22,7 @@ process_new_session_ticket = proc do |nst, rms, cs|
21
22
  end
22
23
  settings_1st = {
23
24
  ca_file: __dir__ + '/../tmp/ca.crt',
25
+ alpn: ['http/1.1', 'http/1.0'],
24
26
  process_new_session_ticket: process_new_session_ticket
25
27
  }
26
28
 
@@ -6,8 +6,11 @@ require_relative 'helper'
6
6
  port = ARGV[0] || 4433
7
7
 
8
8
  tcpserver = TCPServer.open(port)
9
- settings = { crt_file: __dir__ + '/../tmp/server.crt',
10
- key_file: __dir__ + '/../tmp/server.key' }
9
+ settings = {
10
+ crt_file: __dir__ + '/../tmp/server.crt',
11
+ key_file: __dir__ + '/../tmp/server.key',
12
+ alpn: ['http/1.1', 'http/1.0']
13
+ }
11
14
 
12
15
  # rubocop: disable Metrics/BlockLength
13
16
  loop do
@@ -149,14 +149,21 @@ RSpec.describe Server do
149
149
  '-groups P-256:P-384:P-521 -alpn http/1.1',
150
150
  FIXTURES_DIR + '/rsa_rsa.crt',
151
151
  FIXTURES_DIR + '/rsa_rsa.key',
152
- alpn: 'http/1.1'
152
+ alpn: ['http/1.1']
153
+ ],
154
+ [
155
+ true,
156
+ '-groups P-256:P-384:P-521',
157
+ FIXTURES_DIR + '/rsa_rsa.crt',
158
+ FIXTURES_DIR + '/rsa_rsa.key',
159
+ alpn: ['http/1.1']
153
160
  ],
154
161
  [
155
162
  false,
156
163
  '-groups P-256:P-384:P-521 -alpn foo',
157
164
  FIXTURES_DIR + '/rsa_rsa.crt',
158
165
  FIXTURES_DIR + '/rsa_rsa.key',
159
- alpn: 'http/1.1'
166
+ alpn: ['http/1.1']
160
167
  ]
161
168
  # rubocop: enable Metrics/LineLength
162
169
  ].each do |normal, opt, crt, key, settings|
@@ -402,11 +402,6 @@ module TTTLS13
402
402
  @succeed_early_data
403
403
  end
404
404
 
405
- # @return [String]
406
- def negotiated_alpn
407
- @alpn
408
- end
409
-
410
405
  private
411
406
 
412
407
  # @return [Boolean]
@@ -23,6 +23,7 @@ module TTTLS13
23
23
  @signature_scheme = nil # TTTLS13::SignatureScheme
24
24
  @state = 0 # ClientState or ServerState
25
25
  @send_record_size = Message::DEFAULT_RECORD_SIZE_LIMIT
26
+ @alpn = nil # String
26
27
  end
27
28
 
28
29
  # @raise [TTTLS13::Error::ConfigError]
@@ -95,6 +96,11 @@ module TTTLS13
95
96
  @signature_scheme
96
97
  end
97
98
 
99
+ # @return [String]
100
+ def negotiated_alpn
101
+ @alpn
102
+ end
103
+
98
104
  private
99
105
 
100
106
  # @param cipher_suite [TTTLS13::CipherSuite]
@@ -153,11 +153,12 @@ module TTTLS13
153
153
  terminate(:unrecognized_name) unless recognized_server_name?(ch, @crt)
154
154
 
155
155
  # alpn
156
- if !@settings[:alpn].nil? && !@settings[:alpn].empty?
157
- pnl = ch.extensions[
158
- Message::ExtensionType::APPLICATION_LAYER_PROTOCOL_NEGOTIATION
159
- ]&.protocol_name_list || []
160
- @alpn = pnl.find { |p| @settings[:alpn].include?(p) }
156
+ ch_alpn = ch.extensions[
157
+ Message::ExtensionType::APPLICATION_LAYER_PROTOCOL_NEGOTIATION
158
+ ]
159
+ if !@settings[:alpn].nil? && !@settings[:alpn].empty? && !ch_alpn.nil?
160
+ @alpn = ch_alpn.protocol_name_list
161
+ .find { |p| @settings[:alpn].include?(p) }
161
162
 
162
163
  terminate(:no_application_protocol) if @alpn.nil?
163
164
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TTTLS13
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tttls1.3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekuwayama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-11 00:00:00.000000000 Z
11
+ date: 2019-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
- rubygems_version: 3.0.3
194
+ rubygems_version: 3.0.1
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: TLS 1.3 implementation in Ruby