certstore_c 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/certstore/certstore.h +0 -5
- data/ext/certstore/extconf.rb +1 -1
- data/ext/certstore/loader.c +17 -10
- data/lib/certstore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 181ac6a16240752f4b6ae0b0c9c0eba99404e840bc452e182e5528c908ec0e66
|
4
|
+
data.tar.gz: a856de78f86953d352d8f39d43ae264a2b0698633bf7a262bb1d5a87926c8ba4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6b2f662310e81a7f10466bb905328df9c21fc7f0df70b1b7cff508b05267b2febf95eaef5c11baf2a1f1dd0a088a95ed03fe3da349859907dfbe99c3333065f
|
7
|
+
data.tar.gz: 0f5b6f97395ffb962c2902aa9b26f53a94f806e121220a0f9a8d1a78ee8cfad3f15faf2cfdbe43af5b613b1f86b389903c50e84f112c1778fbed276890738a04
|
data/ext/certstore/certstore.h
CHANGED
data/ext/certstore/extconf.rb
CHANGED
@@ -14,7 +14,7 @@ have_library("crypt32")
|
|
14
14
|
have_func("PFXExportCertStoreEx", "Wincrypt.h")
|
15
15
|
|
16
16
|
$LDFLAGS << " -lcrypt32"
|
17
|
-
$CFLAGS << " -std=c99 -fPIC -fms-extensions "
|
17
|
+
$CFLAGS << " -Wall -std=c99 -fPIC -fms-extensions "
|
18
18
|
# $CFLAGS << " -g -O0"
|
19
19
|
|
20
20
|
create_makefile("certstore/certstore")
|
data/ext/certstore/loader.c
CHANGED
@@ -11,6 +11,12 @@
|
|
11
11
|
|
12
12
|
#include <certstore.h>
|
13
13
|
|
14
|
+
struct CertstoreLoader
|
15
|
+
{
|
16
|
+
HCERTSTORE hStore;
|
17
|
+
PCCERT_CONTEXT pContext;
|
18
|
+
};
|
19
|
+
|
14
20
|
static void certstore_loader_free(void* certstore);
|
15
21
|
|
16
22
|
static const rb_data_type_t rb_win_certstore_loader_type = {
|
@@ -29,6 +35,8 @@ static void
|
|
29
35
|
certstore_loader_free(void* ptr)
|
30
36
|
{
|
31
37
|
struct CertstoreLoader* loader = (struct CertstoreLoader*)ptr;
|
38
|
+
if (loader->pContext)
|
39
|
+
CertFreeCertificateContext(loader->pContext);
|
32
40
|
if (loader->hStore)
|
33
41
|
CertCloseStore(loader->hStore, 0);
|
34
42
|
|
@@ -42,6 +50,8 @@ rb_win_certstore_loader_alloc(VALUE klass)
|
|
42
50
|
struct CertstoreLoader* loader;
|
43
51
|
obj = TypedData_Make_Struct(
|
44
52
|
klass, struct CertstoreLoader, &rb_win_certstore_loader_type, loader);
|
53
|
+
loader->hStore = NULL;
|
54
|
+
loader->pContext = NULL;
|
45
55
|
return obj;
|
46
56
|
}
|
47
57
|
|
@@ -146,7 +156,6 @@ certificate_context_to_string(PCCERT_CONTEXT pContext)
|
|
146
156
|
|
147
157
|
len = WideCharToMultiByte(CP_UTF8, 0, wszString, -1, NULL, 0, NULL, NULL);
|
148
158
|
utf8str = ALLOCV_N(CHAR, vUtf8str, len);
|
149
|
-
len = WideCharToMultiByte(CP_UTF8, 0, wszString, -1, NULL, 0, NULL, NULL);
|
150
159
|
WideCharToMultiByte(CP_UTF8, 0, wszString, -1, utf8str, len, NULL, NULL);
|
151
160
|
// malloc ((strlen(base64 cert content) + strlen(header) +
|
152
161
|
// strlen(footer) + 1(null terminator)) length).
|
@@ -188,8 +197,10 @@ rb_win_certstore_loader_each_pem(VALUE self)
|
|
188
197
|
self, struct CertstoreLoader, &rb_win_certstore_loader_type, loader);
|
189
198
|
|
190
199
|
while ((pContext = CertEnumCertificatesInStore(loader->hStore, pContext)) != NULL) {
|
200
|
+
loader->pContext = pContext;
|
191
201
|
VALUE rb_certificate = certificate_context_to_string(pContext);
|
192
202
|
rb_yield(rb_certificate);
|
203
|
+
loader->pContext = NULL;
|
193
204
|
}
|
194
205
|
|
195
206
|
return Qnil;
|
@@ -203,7 +214,9 @@ rb_win_certstore_loader_dispose(VALUE self)
|
|
203
214
|
TypedData_Get_Struct(
|
204
215
|
self, struct CertstoreLoader, &rb_win_certstore_loader_type, loader);
|
205
216
|
|
206
|
-
|
217
|
+
if (loader->pContext)
|
218
|
+
CertFreeCertificateContext(loader->pContext);
|
219
|
+
loader->pContext = NULL;
|
207
220
|
|
208
221
|
return Qnil;
|
209
222
|
}
|
@@ -211,14 +224,8 @@ rb_win_certstore_loader_dispose(VALUE self)
|
|
211
224
|
static VALUE
|
212
225
|
rb_win_certstore_loader_each(VALUE self)
|
213
226
|
{
|
214
|
-
PCCERT_CONTEXT pContext = NULL;
|
215
|
-
struct CertstoreLoader* loader;
|
216
|
-
|
217
227
|
RETURN_ENUMERATOR(self, 0, 0);
|
218
228
|
|
219
|
-
TypedData_Get_Struct(
|
220
|
-
self, struct CertstoreLoader, &rb_win_certstore_loader_type, loader);
|
221
|
-
|
222
229
|
rb_ensure(
|
223
230
|
rb_win_certstore_loader_each_pem, self, rb_win_certstore_loader_dispose, self);
|
224
231
|
|
@@ -293,7 +300,7 @@ rb_win_certstore_loader_add_certificate(VALUE self, VALUE rb_der_cert_bin_str)
|
|
293
300
|
|
294
301
|
if (CertAddEncodedCertificateToStore(loader->hStore,
|
295
302
|
X509_ASN_ENCODING,
|
296
|
-
RSTRING_PTR(rb_der_cert_bin_str),
|
303
|
+
(const BYTE *)RSTRING_PTR(rb_der_cert_bin_str),
|
297
304
|
RSTRING_LEN(rb_der_cert_bin_str),
|
298
305
|
CERT_STORE_ADD_NEW,
|
299
306
|
NULL)) {
|
@@ -474,7 +481,7 @@ rb_win_certstore_loader_export_pfx(VALUE self, VALUE rb_thumbprint, VALUE rb_pas
|
|
474
481
|
ALLOCV_END(vThumbprint);
|
475
482
|
ALLOCV_END(vPassword);
|
476
483
|
|
477
|
-
VALUE rb_str = rb_str_new(pfxPacket.pbData, pfxPacket.cbData);
|
484
|
+
VALUE rb_str = rb_str_new((const char *)pfxPacket.pbData, pfxPacket.cbData);
|
478
485
|
|
479
486
|
CryptMemFree(pfxPacket.pbData);
|
480
487
|
CertCloseStore(hMemoryStore, CERT_CLOSE_STORE_CHECK_FLAG);
|
data/lib/certstore/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: certstore_c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Hatake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|