ocsprf 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +2 -1
- data/lib/ocsp_response_fetch.rb +1 -0
- data/lib/ocsp_response_fetch/cli.rb +34 -7
- data/lib/ocsp_response_fetch/fetcher.rb +1 -1
- data/lib/ocsp_response_fetch/version.rb +1 -1
- data/ocsprf.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e349ecd9345bf80d7a5308bd322bc2278fce43e01a71e4ec52e30eee97b3484
|
4
|
+
data.tar.gz: fc9bcc0f02177740fcd7c6523a3748c4a4791478dab22df0493dd91e85988aa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ba747599accef080af0058fe2a7df871a015a2867956d3db5a7b82f5dfee77d127d74b3478c8d6c6a7369058bd96c63d373d2c03422e4056b72bb3878cdb866
|
7
|
+
data.tar.gz: 479527df9f08fdad7c81c8cca6d248edde034e1400e33b361b5530cefe6991d81b016940530e508bf2cd257fa4a90c56b84fa9efa877eb63a23043f871af8b01
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Actions Status](https://github.com/thekuwayama/ocsprf/workflows/CI/badge.svg)](https://github.com/thekuwayama/ocsprf/actions?workflow=CI)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/4d5bb71e2dca46f5a239/maintainability)](https://codeclimate.com/github/thekuwayama/ocsprf/maintainability)
|
6
6
|
|
7
|
-
OCSP Response Fetch
|
7
|
+
`ocsprf` is OCSP Response Fetch CLI.
|
8
8
|
|
9
9
|
|
10
10
|
## Installation
|
@@ -22,6 +22,7 @@ $ gem install ocsprf
|
|
22
22
|
$ ocsprf --help
|
23
23
|
Usage: ocsprf [options] PATH
|
24
24
|
-i, --issuer PATH issuer certificate path
|
25
|
+
-o, --output PATH output file path
|
25
26
|
-s, --strict strict mode (default false)
|
26
27
|
-v, --verbose verbose mode (default false)
|
27
28
|
```
|
data/lib/ocsp_response_fetch.rb
CHANGED
@@ -9,10 +9,10 @@ module OCSPResponseFetch
|
|
9
9
|
def run
|
10
10
|
subject, opts = parse_options
|
11
11
|
issuer = opts[:issuer]
|
12
|
-
|
13
|
-
|
14
|
-
fetcher = Fetcher.new(subject_cert, issuer_cert)
|
12
|
+
ocsp_response = nil
|
15
13
|
begin
|
14
|
+
subject_cert, issuer_cert = read_certs(subject, issuer)
|
15
|
+
fetcher = Fetcher.new(subject_cert, issuer_cert)
|
16
16
|
ocsp_response = fetcher.run
|
17
17
|
rescue OCSPResponseFetch::Error::RevokedError
|
18
18
|
warn 'error: end entity certificate is revoked'
|
@@ -24,19 +24,26 @@ module OCSPResponseFetch
|
|
24
24
|
end
|
25
25
|
|
26
26
|
warn ocsp_response.to_text if opts[:verbose]
|
27
|
-
|
27
|
+
if opts[:output].nil?
|
28
|
+
puts ocsp_response.to_der
|
29
|
+
else
|
30
|
+
File.write(opts[:output], ocsp_response.to_der)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
private
|
31
35
|
|
32
36
|
# rubocop: disable Metrics/AbcSize
|
37
|
+
# rubocop: disable Metrics/CyclomaticComplexity
|
33
38
|
# rubocop: disable Metrics/MethodLength
|
39
|
+
# rubocop: disable Metrics/PerceivedComplexity
|
34
40
|
def parse_options(argv = ARGV)
|
35
41
|
op = OptionParser.new
|
36
42
|
|
37
43
|
# default value
|
38
44
|
opts = {
|
39
45
|
issuer: nil,
|
46
|
+
output: nil,
|
40
47
|
strict: false,
|
41
48
|
verbose: false
|
42
49
|
}
|
@@ -49,6 +56,14 @@ module OCSPResponseFetch
|
|
49
56
|
opts[:issuer] = v
|
50
57
|
end
|
51
58
|
|
59
|
+
op.on(
|
60
|
+
'-o PATH',
|
61
|
+
'--output PATH',
|
62
|
+
'output file path'
|
63
|
+
) do |v|
|
64
|
+
opts[:output] = v
|
65
|
+
end
|
66
|
+
|
52
67
|
op.on(
|
53
68
|
'-s',
|
54
69
|
'--strict',
|
@@ -90,10 +105,21 @@ module OCSPResponseFetch
|
|
90
105
|
exit 1
|
91
106
|
end
|
92
107
|
|
108
|
+
unless opts[:output].nil?
|
109
|
+
begin
|
110
|
+
FileUtils.touch(opts[:output])
|
111
|
+
rescue Errno::EACCES
|
112
|
+
warn "error file #{opts[:output]} is not writable"
|
113
|
+
exit 1
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
93
117
|
[args[0], opts]
|
94
118
|
end
|
95
119
|
# rubocop: enable Metrics/AbcSize
|
120
|
+
# rubocop: enable Metrics/CyclomaticComplexity
|
96
121
|
# rubocop: enable Metrics/MethodLength
|
122
|
+
# rubocop: enable Metrics/PerceivedComplexity
|
97
123
|
|
98
124
|
# @param subject [String]
|
99
125
|
# @param issuer [String]
|
@@ -114,15 +140,16 @@ module OCSPResponseFetch
|
|
114
140
|
|
115
141
|
begin
|
116
142
|
issuer_cert = get_issuer_cert(ca_issuer)
|
117
|
-
rescue OpenSSL::X509::CertificateError,
|
118
|
-
|
143
|
+
rescue OpenSSL::X509::CertificateError,
|
144
|
+
Net::OpenTimeout, SystemCallError
|
145
|
+
raise OCSPResponseFetch::Error::FetchFailedError,
|
119
146
|
'Failed to get the issuser Certificate'
|
120
147
|
end
|
121
148
|
else
|
122
149
|
begin
|
123
150
|
issuer_cert = OpenSSL::X509::Certificate.new(File.read(issuer))
|
124
151
|
rescue OpenSSL::X509::CertificateError
|
125
|
-
raise OCSPResponseFetch::Error::
|
152
|
+
raise OCSPResponseFetch::Error::FetchFailedError,
|
126
153
|
'Failed to get the issuser Certificate'
|
127
154
|
end
|
128
155
|
end
|
@@ -44,7 +44,7 @@ module OCSPResponseFetch
|
|
44
44
|
Timeout.timeout(2) do
|
45
45
|
ocsp_response = send_ocsp_request(ocsp_request, ocsp_uri)
|
46
46
|
end
|
47
|
-
rescue Timeout::Error
|
47
|
+
rescue Timeout::Error, SystemCallError
|
48
48
|
raise OCSPResponseFetch::Error::FetchFailedError,
|
49
49
|
'Timeout to access OCSP Responder'
|
50
50
|
end
|
data/ocsprf.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocsprf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thekuwayama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fileutils
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: openssl
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|