Skip to content

Commit 8aa7f61

Browse files
Peter Deaconfreddy77
authored andcommitted
odbc: Add support for ODBC connection attribute ServerCertificate
Signed-off-by: Peter Deacon <peterd@iea-software.com>
1 parent 01c0d37 commit 8aa7f61

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

doc/userguide.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ Once project files are created you can open them with your environment.</para>
618618

619619
<para>You can download FreeTDS binaries for Windows from AppVeyor (the hosted CI platform used).</para>
620620

621-
<para>There is a .zip file available as artifact of every sucessful build.
621+
<para>There is a .zip file available as artifact of every successful build.
622622

623623
The list of builds is at
624624
<ulink url="https://ci.appveyor.com/project/FreeTDS/freetds/history">https://ci.appveyor.com/project/FreeTDS/freetds/history</ulink>.
@@ -1254,7 +1254,7 @@ This is the name of the database container in the server you are connecting to.<
12541254
<entry>File that holds root certificates (in PEM format) to verify server certificate, used during an encrypted connection.
12551255
If not specify or empty any certificate will be accepted from server.
12561256
If you specify <literal>system</literal> &freetds; will use system wide certificate list.
1257-
If a certiticate is not installed server can generate a self signed certificate, in this case is useful to disable certificate validation (which is the default).
1257+
If a certificate is not installed server can generate a self signed certificate, in this case is useful to disable certificate validation (which is the default).
12581258
Note that is not possible to specify a directory as usually database servers does not use a certificate signed by a public global certification authority.
12591259
</entry>
12601260
</row>
@@ -2044,6 +2044,17 @@ The ODBC tests all build their own <filename>odbc.ini</filename> and try to redi
20442044
<entry>Specify encryption.
20452045
Similar to encryption on &freetdsconf; but Microsoft compatible.</entry>
20462046
</row>
2047+
<row>
2048+
<entry><literal>ServerCertificate</literal></entry>
2049+
<entry>Any</entry>
2050+
<entry>none</entry>
2051+
<entry>File that holds root certificates (in PEM format) to verify server certificate, used during an encrypted connection.
2052+
If not specify or empty any certificate will be accepted from server.
2053+
If you specify <literal>system</literal> &freetds; will use system wide certificate list.
2054+
If a certificate is not installed server can generate a self signed certificate, in this case is useful to disable certificate validation (which is the default).
2055+
Note that is not possible to specify a directory as usually database servers does not use a certificate signed by a public global certification authority.
2056+
Microsoft compatible.</entry>
2057+
</row>
20472058
<row>
20482059
<entry><literal>HostNameInCertificate</literal></entry>
20492060
<entry>Server name</entry>

include/freetds/odbc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ bool get_login_info(HWND hwndParent, TDSLOGIN * login);
528528
ODBC_PARAM(ApplicationIntent) \
529529
ODBC_PARAM(Timeout) \
530530
ODBC_PARAM(Encrypt) \
531-
ODBC_PARAM(HostNameInCertificate)
531+
ODBC_PARAM(HostNameInCertificate) \
532+
ODBC_PARAM(ServerCertificate)
532533

533534
#define ODBC_PARAM(p) ODBC_PARAM_##p,
534535
enum {

src/odbc/connectparams.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSLOGIN * login)
260260
if (myGetPrivateProfileString(DSN, odbc_param_Encrypt, tmp) > 0)
261261
tds_parse_conf_section(TDS_STR_ENCRYPTION, odbc_encrypt2encryption(tmp), login);
262262

263+
if (myGetPrivateProfileString(DSN, odbc_param_ServerCertificate, tmp) > 0)
264+
tds_parse_conf_section(TDS_STR_CAFILE, tmp, login);
265+
263266
if (myGetPrivateProfileString(DSN, odbc_param_UseNTLMv2, tmp) > 0)
264267
tds_parse_conf_section(TDS_STR_USENTLMV2, tmp, login);
265268

@@ -482,6 +485,8 @@ odbc_parse_connect_string(TDS_ERRS *errs, const char *connect_string, const char
482485
tds_parse_conf_section(TDS_STR_ENCRYPTION, tds_dstr_cstr(&value), login);
483486
} else if (CHK_PARAM(Encrypt)) {
484487
tds_parse_conf_section(TDS_STR_ENCRYPTION, odbc_encrypt2encryption(tds_dstr_cstr(&value)), login);
488+
} else if (CHK_PARAM(ServerCertificate)) {
489+
tds_parse_conf_section(TDS_STR_CAFILE, tds_dstr_cstr(&value), login);
485490
} else if (CHK_PARAM(UseNTLMv2)) {
486491
tds_parse_conf_section(TDS_STR_USENTLMV2, tds_dstr_cstr(&value), login);
487492
} else if (CHK_PARAM(REALM)) {

0 commit comments

Comments
 (0)