ext/certstore/loader.c in certstore_c-0.1.2.rc vs ext/certstore/loader.c in certstore_c-0.1.2
- old
+ new
@@ -79,17 +79,23 @@
CHAR *certHeader = "-----BEGIN CERTIFICATE-----\n";
CHAR *certFooter = "\n-----END CERTIFICATE-----";
CHAR errBuf[256];
DWORD errCode;
+#ifndef CRYPT_STRING_NOCRLF
+ #define CRYPT_STRING_NOCRLF 0x40000000
+#endif
+
if (!CryptBinaryToStringW(pContext->pbCertEncoded, pContext->cbCertEncoded,
- CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &cchString)) {
+ CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF,
+ NULL, &cchString)) {
rb_raise(rb_eCertLoaderError, "cannot obtain certificate string length.");
}
wszString = malloc(sizeof(WCHAR) * cchString);
CryptBinaryToStringW(pContext->pbCertEncoded, pContext->cbCertEncoded,
- CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, wszString, &cchString);
+ CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF,
+ wszString, &cchString);
utf8str = wstr_to_mbstr(CP_UTF8, wszString, -1);
// malloc sizeof CHAR * ((base64 cert content + header + footer) length).
certificate = malloc(sizeof(CHAR) * (strlen(utf8str) + strlen(certHeader) + strlen(certFooter)));
sprintf(certificate, "%s%s%s", certHeader, utf8str, certFooter);