Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
308ffcab
Commit
308ffcab
authored
Oct 27, 2020
by
Jeremy Cohen
Browse files
Updating SSL connection example
parent
297f6551
Changes
1
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
308ffcab
...
...
@@ -517,7 +517,7 @@ initialize OpenSSL and create a context. You can do that in two ways:
/* An Hiredis SSL context. It holds SSL configuration and can be reused across
* many contexts.
*/
redisSSLContext
*
ssl
;
redisSSLContext
*
ssl
_context
;
/* An error variable to indicate what went wrong, if the context fails to
* initialize.
...
...
@@ -532,17 +532,23 @@ redisSSLContextError ssl_error;
redisInitOpenSSL
();
/* Create SSL context */
ssl
=
redisCreateSSLContext
(
ssl
_context
=
redisCreateSSLContext
(
"cacertbundle.crt"
,
/* File name of trusted CA/ca bundle file, optional */
"/path/to/certs"
,
/* Path of trusted certificates, optional */
"client_cert.pem"
,
/* File name of client certificate file, optional */
"client_key.pem"
,
/* File name of client private key, optional */
"redis.mydomain.com"
,
/* Server name to request (SNI), optional */
&
ssl_error
)
!=
REDIS_OK
)
{
printf
(
"SSL error: %s
\n
"
,
redisSSLContextGetError
(
ssl_error
);
/* Abort... */
}
&
ssl_error
);
if
(
ssl_context
==
NULL
||
ssl_error
!=
0
)
{
/* Handle error and abort... */
/* e.g.
printf("SSL error: %s\n",
(ssl_error != 0) ?
redisSSLContextGetError(ssl_error) : "Unknown error");
// Abort
*/
}
/* Create Redis context and establish connection */
c
=
redisConnect
(
"localhost"
,
6443
);
...
...
@@ -551,7 +557,7 @@ if (c == NULL || c->err) {
}
/* Negotiate SSL/TLS */
if
(
redisInitiateSSLWithContext
(
c
,
ssl
)
!=
REDIS_OK
)
{
if
(
redisInitiateSSLWithContext
(
c
,
ssl
_context
)
!=
REDIS_OK
)
{
/* Handle error, in c->err / c->errstr */
}
```
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment