as2 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e21a1d3326b7db528a205964fb6c5e99656ea20e4ad7dcba0877088fdd86104
4
- data.tar.gz: c46538361b3cdb28f6b97a602465adea7dea2f348dbdc54fd18c33ca7a496801
3
+ metadata.gz: 7a467f304fd7955e9f787078b8bbda6277e111e84e75d2cc02c935d6ccc00916
4
+ data.tar.gz: b75996e0b5064d1b4133f9ed8db0b9f629cb44746ade335edcd3a2fa04de0edf
5
5
  SHA512:
6
- metadata.gz: 52189a26063743097ea72abfe0b12e21866417ab60af8633b581eab7c1902ebb32bf904538daf4301f5320c0cbfd730d94c1aa14f6a365d0ea270158f649565c
7
- data.tar.gz: ec40485fcd9e7f7f38cbc3649c3b7c84986ebc1be2242a3208c9563d42bea239fb8d4f38a73bd0ce580e54e2371890a45689d138b55c5eccc0c489b6c7526a45
6
+ metadata.gz: b8b50c0291eed98d9f74333e094bf1a59cf4bedb987592082dddc04118e319dd85121f8434391fb473783320b6388ec836d0fe54901b02b8c3cdf70f95eb93b6
7
+ data.tar.gz: db4e30dba47bd613b3b9b5e0e47d33951e527a31249af79ce7f2073c66035cc9a3aa3a8ba5a88c0163b4e06eec814d6ac2bf48ee060935cc22ec57762bdd2b10
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.11.0 September 14, 2023
2
+
3
+ * Allow configuration of which encryption cipher to use when sending outbound messages. [#35](https://github.com/alexdean/as2/pull/35)
4
+
1
5
  ## 0.10.0 September 13, 2023
2
6
 
3
7
  support for separate signing & encryption certificates for partners. [#34](https://github.com/alexdean/as2/pull/34)
data/lib/as2/client.rb CHANGED
@@ -8,6 +8,10 @@ module As2
8
8
  ['v0', 'v1']
9
9
  end
10
10
 
11
+ def self.valid_encryption_ciphers
12
+ OpenSSL::Cipher.ciphers
13
+ end
14
+
11
15
  # @param [As2::Config::Partner,String] partner The partner to send a message to.
12
16
  # If a string is given, it should be a partner name which has been registered
13
17
  # via a call to #add_partner.
@@ -45,6 +49,10 @@ module As2
45
49
  # * If content parameter is specified, file_name is only used to tell the
46
50
  # partner the original name of the file.
47
51
  #
52
+ # TODO: refactor to separate "build an outbound message" from "send an outbound message"
53
+ # main benefit would be allowing the test suite to be more straightforward.
54
+ # (wouldn't need webmock just to verify what kind of message we built...)
55
+ #
48
56
  # @param [String] file_name
49
57
  # @param [String] content
50
58
  # @param [String] content_type This is the MIME Content-Type describing the `content` param,
@@ -82,8 +90,11 @@ module As2
82
90
  file_name: file_name
83
91
  )
84
92
 
85
- cipher = OpenSSL::Cipher::AES256.new(:CBC) # default, but we might have to make this configurable
86
- encrypted = OpenSSL::PKCS7.encrypt([@partner.encryption_certificate], request_body, cipher)
93
+ encrypted = OpenSSL::PKCS7.encrypt(
94
+ [@partner.encryption_certificate],
95
+ request_body,
96
+ @partner.encryption_cipher_instance
97
+ )
87
98
 
88
99
  # > HTTP can handle binary data and so there is no need to use the
89
100
  # > content transfer encodings of MIME
data/lib/as2/config.rb CHANGED
@@ -12,7 +12,12 @@ module As2
12
12
  end
13
13
  end
14
14
 
15
- class Partner < Struct.new :name, :url, :encryption_certificate, :signing_certificate, :tls_verify_mode, :mdn_format, :outbound_format
15
+ class Partner < Struct.new :name, :url, :encryption_certificate, :encryption_cipher, :signing_certificate, :tls_verify_mode, :mdn_format, :outbound_format
16
+ def initialize
17
+ # set default.
18
+ self.encryption_cipher = 'aes-256-cbc'
19
+ end
20
+
16
21
  def url=(url)
17
22
  if url.kind_of? String
18
23
  self['url'] = URI.parse url
@@ -49,6 +54,19 @@ module As2
49
54
  self['encryption_certificate'] = As2::Config.build_certificate(certificate)
50
55
  end
51
56
 
57
+ def encryption_cipher=(cipher)
58
+ cipher_s = cipher.to_s
59
+ valid_ciphers = As2::Client.valid_encryption_ciphers
60
+ if !valid_ciphers.include?(cipher_s)
61
+ raise ArgumentError, "encryption_cipher '#{cipher_s}' must be one of #{valid_ciphers.inspect}"
62
+ end
63
+ self['encryption_cipher'] = cipher_s
64
+ end
65
+
66
+ def encryption_cipher_instance
67
+ OpenSSL::Cipher.new(encryption_cipher)
68
+ end
69
+
52
70
  def signing_certificate=(certificate)
53
71
  self['signing_certificate'] = As2::Config.build_certificate(certificate)
54
72
  end
data/lib/as2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module As2
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: as2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OfficeLuv
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-09-13 00:00:00.000000000 Z
12
+ date: 2023-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mail