win32-certstore 0.3.0 → 0.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a68ca02b433defcda38f35fed8359b02060cb49b6935ae6da348863ed471bd86
|
4
|
+
data.tar.gz: 3c8ea23c6116c27a414d87fcf49081c787b9d9f9fb8a0395f05daeada10240ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88a61f620f9a9e14d58f535248d36e87ed7ca6ba5c8eb787fc937e4090fbb52142cf9ce683c98e25d7008cd90e9c54a5b1af87d9500b8459f34d438629c95856
|
7
|
+
data.tar.gz: 9a55a43bf1330cface6dc59440aa477c062a37b132c7303404be4036fc0871d76765cbd6f683edf1fe4fc22ff0250309d4268a8ef5ed39e81eac1ebf8ed9282c
|
data/lib/win32/certstore.rb
CHANGED
@@ -60,11 +60,12 @@ module Win32
|
|
60
60
|
#
|
61
61
|
# @param path [String] Path of the certificate that should be imported
|
62
62
|
# @param password [String] Password of the certificate if it is protected
|
63
|
+
# @param key_properties [Integer] dwFlags used to specify properties of the pfx key, see certstore/store_base.rb cert_add_pfx function
|
63
64
|
#
|
64
65
|
# @return [Boolean]
|
65
66
|
#
|
66
|
-
def add_pfx(path, password)
|
67
|
-
cert_add_pfx(certstore_handler, path, password)
|
67
|
+
def add_pfx(path, password, key_properties = 0)
|
68
|
+
cert_add_pfx(certstore_handler, path, password, key_properties)
|
68
69
|
end
|
69
70
|
|
70
71
|
# Return `OpenSSL::X509` certificate object
|
@@ -113,17 +113,17 @@ module Win32
|
|
113
113
|
|
114
114
|
class FILETIME < FFI::Struct
|
115
115
|
layout :dwLowDateTime, DWORD,
|
116
|
-
|
116
|
+
:dwHighDateTime, DWORD
|
117
117
|
end
|
118
118
|
|
119
119
|
class CRYPT_INTEGER_BLOB < FFI::Struct
|
120
120
|
layout :cbData, DWORD, # Count, in bytes, of data
|
121
|
-
|
121
|
+
:pbData, :pointer # Pointer to data buffer
|
122
122
|
end
|
123
123
|
|
124
124
|
class CRYPT_NAME_BLOB < FFI::Struct
|
125
125
|
layout :cbData, DWORD, # Count, in bytes, of data
|
126
|
-
|
126
|
+
:pbData, :pointer # Pointer to data buffer
|
127
127
|
def initialize(str = nil)
|
128
128
|
super(nil)
|
129
129
|
if str
|
@@ -134,7 +134,7 @@ module Win32
|
|
134
134
|
|
135
135
|
class CRYPT_HASH_BLOB < FFI::Struct
|
136
136
|
layout :cbData, DWORD, # Count, in bytes, of data
|
137
|
-
|
137
|
+
:pbData, :pointer # Pointer to data buffer
|
138
138
|
|
139
139
|
def initialize(str = nil)
|
140
140
|
super(nil)
|
@@ -151,7 +151,7 @@ module Win32
|
|
151
151
|
|
152
152
|
class CRYPT_DATA_BLOB < FFI::Struct
|
153
153
|
layout :cbData, DWORD, # Count, in bytes, of data
|
154
|
-
|
154
|
+
:pbData, :pointer # Pointer to data buffer
|
155
155
|
|
156
156
|
def initialize(str = nil)
|
157
157
|
super(nil)
|
@@ -164,47 +164,47 @@ module Win32
|
|
164
164
|
|
165
165
|
class CERT_EXTENSION < FFI::Struct
|
166
166
|
layout :pszObjId, LPTSTR,
|
167
|
-
|
168
|
-
|
167
|
+
:fCritical, BOOL,
|
168
|
+
:Value, CRYPT_INTEGER_BLOB
|
169
169
|
end
|
170
170
|
|
171
171
|
class CRYPT_BIT_BLOB < FFI::Struct
|
172
172
|
layout :cbData, DWORD,
|
173
|
-
|
174
|
-
|
173
|
+
:pbData, BYTE,
|
174
|
+
:cUnusedBits, DWORD
|
175
175
|
end
|
176
176
|
|
177
177
|
class CRYPT_ALGORITHM_IDENTIFIER < FFI::Struct
|
178
178
|
layout :pszObjId, LPSTR,
|
179
|
-
|
179
|
+
:Parameters, CRYPT_INTEGER_BLOB
|
180
180
|
end
|
181
181
|
|
182
182
|
class CERT_PUBLIC_KEY_INFO < FFI::Struct
|
183
183
|
layout :Algorithm, CRYPT_ALGORITHM_IDENTIFIER,
|
184
|
-
|
184
|
+
:PublicKey, CRYPT_BIT_BLOB
|
185
185
|
end
|
186
186
|
|
187
187
|
class CERT_INFO < FFI::Struct
|
188
188
|
layout :dwVersion, DWORD,
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
189
|
+
:SerialNumber, CRYPT_INTEGER_BLOB,
|
190
|
+
:SignatureAlgorithm, CRYPT_ALGORITHM_IDENTIFIER,
|
191
|
+
:Issuer, CRYPT_NAME_BLOB,
|
192
|
+
:NotBefore, FILETIME,
|
193
|
+
:NotAfter, FILETIME,
|
194
|
+
:Subject, CRYPT_NAME_BLOB,
|
195
|
+
:SubjectPublicKeyInfo, CERT_PUBLIC_KEY_INFO,
|
196
|
+
:IssuerUniqueId, CRYPT_BIT_BLOB,
|
197
|
+
:SubjectUniqueId, CRYPT_BIT_BLOB,
|
198
|
+
:cExtension, DWORD,
|
199
|
+
:rgExtension, CERT_EXTENSION
|
200
200
|
end
|
201
201
|
|
202
202
|
class CERT_CONTEXT < FFI::Struct
|
203
203
|
layout :dwCertEncodingType, DWORD,
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
204
|
+
:pbCertEncoded, BYTE,
|
205
|
+
:cbCertEncoded, DWORD,
|
206
|
+
:pCertInfo, CERT_INFO,
|
207
|
+
:hCertStore, HCERTSTORE
|
208
208
|
end
|
209
209
|
|
210
210
|
###############################################################################
|
@@ -28,6 +28,7 @@ module Win32
|
|
28
28
|
if cmd.error!
|
29
29
|
raise Mixlib::ShellOut::ShellCommandFailed, cmd.error!
|
30
30
|
end
|
31
|
+
|
31
32
|
cmd
|
32
33
|
end
|
33
34
|
|
@@ -96,7 +97,7 @@ module Win32
|
|
96
97
|
"-InputFormat None",
|
97
98
|
]
|
98
99
|
|
99
|
-
"powershell.exe #{flags.join(
|
100
|
+
"powershell.exe #{flags.join(" ")} -Command \"#{script.gsub('"', '\"')}\""
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
@@ -57,16 +57,18 @@ module Win32
|
|
57
57
|
# @param certstore_handler [FFI::Pointer] Handle of the store where certificate should be imported
|
58
58
|
# @param path [String] Path of the certificate that should be imported
|
59
59
|
# @param password [String] Password of the certificate
|
60
|
+
# @param key_properties [Integer] dwFlags used to specify properties of the pfx key, see link above
|
60
61
|
#
|
61
62
|
# @return [Boolean]
|
62
63
|
#
|
63
64
|
# @raise [SystemCallError] when Crypt API would not be able to perform some action
|
64
65
|
#
|
65
|
-
def cert_add_pfx(certstore_handler, path, password = "")
|
66
|
+
def cert_add_pfx(certstore_handler, path, password = "", key_properties = 0)
|
66
67
|
cert_added = false
|
67
68
|
# Imports a PFX BLOB and returns the handle of a store
|
68
|
-
pfx_cert_store = PFXImportCertStore(CRYPT_DATA_BLOB.new(File.binread(path)), wstring(password),
|
69
|
+
pfx_cert_store = PFXImportCertStore(CRYPT_DATA_BLOB.new(File.binread(path)), wstring(password), key_properties)
|
69
70
|
raise if pfx_cert_store.null?
|
71
|
+
|
70
72
|
# Find all the certificate contexts in certificate store and add them ino the store
|
71
73
|
while (cert_context = CertEnumCertificatesInStore(pfx_cert_store, cert_context)) && (not cert_context.null?)
|
72
74
|
# Add certificate context to the certificate store
|
@@ -123,7 +125,7 @@ module Win32
|
|
123
125
|
begin
|
124
126
|
cert_args = cert_find_args(store_handler, thumbprint)
|
125
127
|
pcert_context = CertFindCertificateInStore(*cert_args)
|
126
|
-
|
128
|
+
unless pcert_context.null?
|
127
129
|
cert_delete_flag = CertDeleteCertificateFromStore(CertDuplicateCertificateContext(pcert_context)) || lookup_error
|
128
130
|
end
|
129
131
|
CertFreeCertificateContext(pcert_context)
|
@@ -149,6 +151,7 @@ module Win32
|
|
149
151
|
# search_token => CN, RDN or any certificate attribute
|
150
152
|
def cert_search(store_handler, search_token)
|
151
153
|
raise ArgumentError, "Invalid search token" if !search_token || search_token.strip.empty?
|
154
|
+
|
152
155
|
certificate_list = []
|
153
156
|
begin
|
154
157
|
while (pcert_context = CertEnumCertificatesInStore(store_handler, pcert_context)) && !pcert_context.null?
|
@@ -217,6 +220,7 @@ module Win32
|
|
217
220
|
# Verify OpenSSL::X509::Certificate object
|
218
221
|
def verify_certificate(cert_pem)
|
219
222
|
return "Certificate not found" if cert_pem.empty?
|
223
|
+
|
220
224
|
valid_duration?(build_openssl_obj(cert_pem))
|
221
225
|
end
|
222
226
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-certstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
|
108
|
-
rubygems_version: 2.7.6
|
107
|
+
rubygems_version: 3.0.3
|
109
108
|
signing_key:
|
110
109
|
specification_version: 4
|
111
110
|
summary: Ruby library for accessing the certificate store on Windows.
|