https://github.com/alexwayfer/faraday-pkcs7
Faraday middleware for encryption and decryption PKCS7 containers
https://github.com/alexwayfer/faraday-pkcs7
Last synced: 4 months ago
JSON representation
Faraday middleware for encryption and decryption PKCS7 containers
- Host: GitHub
- URL: https://github.com/alexwayfer/faraday-pkcs7
- Owner: AlexWayfer
- License: mit
- Created: 2021-10-06T14:13:01.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-27T21:35:36.000Z (about 1 year ago)
- Last Synced: 2025-04-03T13:12:12.433Z (about 1 year ago)
- Language: Ruby
- Size: 76.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Faraday PKCS7
[](https://rubygems.org/gems/faraday-pkcs7)
[](LICENSE.md)
Faraday middleware for encryption and decryption PKCS7 containers.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'faraday-pkcs7'
```
And then execute:
```shell
bundle install
```
Or install it yourself as:
```shell
gem install faraday-pkcs7
```
## Usage
```ruby
require 'faraday/pkcs7'
client_cert = OpenSSL::X509::Certificate.new(File.read('path/to/cer_file'))
client_key = OpenSSL::PKey::RSA.new(File.read('path/to/key_file'), 'passphrase or empty string')
server_cert = OpenSSL::X509::Certificate.new(File.read('path/to/cer_file'))
cert_store = OpenSSL::X509::Store.new
Faraday.new(
url: 'https://example.com/api/'
) do |faraday|
faraday.use :pkcs7,
encrypt: false,
encryption_options: {
key: client_key,
certificate: client_cert,
flags: OpenSSL::PKCS7::BINARY | OpenSSL::PKCS7::NOCERTS | OpenSSL::PKCS7::NOCHAIN
},
decrypt: false,
decryption_options: {
ca_store: cert_store,
public_certificate: server_cert,
flags: OpenSSL::PKCS7::NOVERIFY
}
end
```
Options are optional, by default encryption and decryption are enabled. When disabled — there are only signing
without encryption and verifying without decryption.
For `encryption_options` and `decryption_options` see underlying gem: https://github.com/dmuneras/pkcs7-cryptographer
## Development
After checking out the repo, run `bin/setup` to install dependencies.
Then, run `bin/test` to run the tests.
To install this gem onto your local machine, run `rake build`.
To release a new version, make a commit with a message such as "Bumped to 0.0.2" and then run `rake release`.
See how it works [here](https://bundler.io/guides/creating_gem.html#releasing-the-gem).
## Contributing
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/faraday-pkcs7).
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).