diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2018-12-30 16:00:43 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2018-12-30 16:02:08 +0100 |
commit | 7cebddc7f20385e7fe6f5c3dea83aa8209ffafad (patch) | |
tree | de04af5f37e67d5d18a7dcbbf5031af67ba871c2 /doc/examples | |
parent | dd06453978fd6b398d50643077f092c50fb1b116 (diff) | |
download | gnutls-7cebddc7f20385e7fe6f5c3dea83aa8209ffafad.tar.gz |
examples: use a valid DNS name
This prevents a gnutls server from sending an unexpected message
alert due to invalid DNS name encoding, if the example is not modified.
Resolves: #663
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'doc/examples')
-rw-r--r-- | doc/examples/ex-client-dtls.c | 6 | ||||
-rw-r--r-- | doc/examples/ex-client-resume.c | 6 | ||||
-rw-r--r-- | doc/examples/ex-client-x509-3.1.c | 6 | ||||
-rw-r--r-- | doc/examples/ex-client-x509.c | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/doc/examples/ex-client-dtls.c b/doc/examples/ex-client-dtls.c index 0a5aef3204..6c1b59bb82 100644 --- a/doc/examples/ex-client-dtls.c +++ b/doc/examples/ex-client-dtls.c @@ -56,10 +56,10 @@ int main(void) /* put the x509 credentials to the current session */ CHECK(gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred)); - CHECK(gnutls_server_name_set(session, GNUTLS_NAME_DNS, "my_host_name", - strlen("my_host_name"))); + CHECK(gnutls_server_name_set(session, GNUTLS_NAME_DNS, "www.example.com", + strlen("www.example.com"))); - gnutls_session_set_verify_cert(session, "my_host_name", 0); + gnutls_session_set_verify_cert(session, "www.example.com", 0); /* connect to the peer */ sd = udp_connect(); diff --git a/doc/examples/ex-client-resume.c b/doc/examples/ex-client-resume.c index cf67bfcf1b..69e798e295 100644 --- a/doc/examples/ex-client-resume.c +++ b/doc/examples/ex-client-resume.c @@ -51,9 +51,9 @@ int main(void) CHECK(gnutls_init(&session, GNUTLS_CLIENT)); CHECK(gnutls_server_name_set(session, GNUTLS_NAME_DNS, - "my_host_name", - strlen("my_host_name"))); - gnutls_session_set_verify_cert(session, "my_host_name", 0); + "www.example.com", + strlen("www.example.com"))); + gnutls_session_set_verify_cert(session, "www.example.com", 0); CHECK(gnutls_set_default_priority(session)); diff --git a/doc/examples/ex-client-x509-3.1.c b/doc/examples/ex-client-x509-3.1.c index a6cc5241c0..ec03b15d00 100644 --- a/doc/examples/ex-client-x509-3.1.c +++ b/doc/examples/ex-client-x509-3.1.c @@ -62,10 +62,10 @@ int main(void) */ CHECK(gnutls_init(&session, GNUTLS_CLIENT)); - gnutls_session_set_ptr(session, (void *) "my_host_name"); + gnutls_session_set_ptr(session, (void *) "www.example.com"); - gnutls_server_name_set(session, GNUTLS_NAME_DNS, "my_host_name", - strlen("my_host_name")); + gnutls_server_name_set(session, GNUTLS_NAME_DNS, "www.example.com", + strlen("www.example.com")); /* use default priorities */ CHECK(gnutls_set_default_priority(session)); diff --git a/doc/examples/ex-client-x509.c b/doc/examples/ex-client-x509.c index 0dc23bff37..64e5eed4ad 100644 --- a/doc/examples/ex-client-x509.c +++ b/doc/examples/ex-client-x509.c @@ -57,8 +57,8 @@ int main(void) /* Initialize TLS session */ CHECK(gnutls_init(&session, GNUTLS_CLIENT)); - CHECK(gnutls_server_name_set(session, GNUTLS_NAME_DNS, "my_host_name", - strlen("my_host_name"))); + CHECK(gnutls_server_name_set(session, GNUTLS_NAME_DNS, "www.example.com", + strlen("www.example.com"))); /* It is recommended to use the default priorities */ CHECK(gnutls_set_default_priority(session)); @@ -66,7 +66,7 @@ int main(void) /* put the x509 credentials to the current session */ CHECK(gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred)); - gnutls_session_set_verify_cert(session, "my_host_name", 0); + gnutls_session_set_verify_cert(session, "www.example.com", 0); /* connect to the peer */ |