summaryrefslogtreecommitdiff
path: root/manual/html_node/Echo-server-with-SRP-authentication.html
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-01-02 21:21:18 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-01-02 21:21:43 +0100
commit040fc0f6f24d9e45fa017197843ae52598290fe2 (patch)
tree6cb5a2aaf70ef3f96598b6a733cba7ceba873d4d /manual/html_node/Echo-server-with-SRP-authentication.html
parent782fe4087bf4c1d1f4e11d07862d9b84b1209c38 (diff)
downloadgnutls-040fc0f6f24d9e45fa017197843ae52598290fe2.tar.gz
updated manual
Diffstat (limited to 'manual/html_node/Echo-server-with-SRP-authentication.html')
-rw-r--r--manual/html_node/Echo-server-with-SRP-authentication.html59
1 files changed, 25 insertions, 34 deletions
diff --git a/manual/html_node/Echo-server-with-SRP-authentication.html b/manual/html_node/Echo-server-with-SRP-authentication.html
index e7e2b2e3ed..968fe48a29 100644
--- a/manual/html_node/Echo-server-with-SRP-authentication.html
+++ b/manual/html_node/Echo-server-with-SRP-authentication.html
@@ -1,9 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
-<!-- This manual is last updated 17 November 2012 for version
-3.1.5 of GnuTLS.
+<!-- This manual is last updated 31 December 2012 for version
+3.1.6 of GnuTLS.
Copyright (C) 2001-2012 Free Software Foundation, Inc.
+Copyright (C) 2001-2012 Nikos Mavrogiannopoulos
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -13,10 +14,10 @@ copy of the license is included in the section entitled "GNU Free
Documentation License". -->
<!-- Created by GNU Texinfo 4.13.90, http://www.gnu.org/software/texinfo/ -->
<head>
-<title>GnuTLS 3.1.5: Echo server with SRP authentication</title>
+<title>GnuTLS 3.1.6: Echo server with SRP authentication</title>
-<meta name="description" content="GnuTLS 3.1.5: Echo server with SRP authentication">
-<meta name="keywords" content="GnuTLS 3.1.5: Echo server with SRP authentication">
+<meta name="description" content="GnuTLS 3.1.6: Echo server with SRP authentication">
+<meta name="keywords" content="GnuTLS 3.1.6: Echo server with SRP authentication">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
@@ -161,7 +162,7 @@ Next: <a href="Echo-server-with-anonymous-authentication.html#Echo-server-with-a
</div>
<hr>
<a name="Echo-server-with-SRP-authentication-1"></a>
-<h4 class="subsection">9.2.3 Echo server with <acronym>SRP</acronym> authentication</h4>
+<h4 class="subsection">7.2.3 Echo server with <acronym>SRP</acronym> authentication</h4>
<p>This is a server which supports <acronym>SRP</acronym> authentication. It is
also possible to combine this functionality with a certificate
@@ -198,31 +199,6 @@ server. Here it is separate for simplicity.
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
-/* These are global */
-gnutls_srp_server_credentials_t srp_cred;
-gnutls_certificate_credentials_t cert_cred;
-
-static gnutls_session_t
-initialize_tls_session (void)
-{
- gnutls_session_t session;
-
- gnutls_init (&amp;session, GNUTLS_SERVER);
-
- gnutls_priority_set_direct (session, &quot;NORMAL:-KX-ALL:+SRP:+SRP-DSS:+SRP-RSA&quot;, NULL);
-
- gnutls_credentials_set (session, GNUTLS_CRD_SRP, srp_cred);
- /* for the certificate authenticated ciphersuites.
- */
- gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cert_cred);
-
- /* request client certificate if any.
- */
- gnutls_certificate_server_set_request (session, GNUTLS_CERT_IGNORE);
-
- return session;
-}
-
int
main (void)
{
@@ -233,6 +209,8 @@ main (void)
socklen_t client_len;
char topbuf[512];
gnutls_session_t session;
+ gnutls_srp_server_credentials_t srp_cred;
+ gnutls_certificate_credentials_t cert_cred;
char buffer[MAX_BUF + 1];
int optval = 1;
char name[256];
@@ -276,7 +254,17 @@ main (void)
client_len = sizeof (sa_cli);
for (;;)
{
- session = initialize_tls_session ();
+ gnutls_init (&amp;session, GNUTLS_SERVER);
+ gnutls_priority_set_direct (session,
+ &quot;NORMAL:-KX-ALL:+SRP:+SRP-DSS:+SRP-RSA&quot;, NULL);
+ gnutls_credentials_set (session, GNUTLS_CRD_SRP, srp_cred);
+ /* for the certificate authenticated ciphersuites.
+ */
+ gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cert_cred);
+
+ /* request client certificate if any.
+ */
+ gnutls_certificate_server_set_request (session, GNUTLS_CERT_IGNORE);
sd = accept (listen_sd, (struct sockaddr *) &amp; sa_cli, &amp;client_len);
@@ -307,7 +295,6 @@ main (void)
for (;;)
{
- memset (buffer, 0, MAX_BUF + 1);
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
@@ -315,6 +302,10 @@ main (void)
printf (&quot;\n- Peer has closed the GnuTLS connection\n&quot;);
break;
}
+ else if (ret &lt; 0 &amp;&amp; gnutls_error_is_fatal (ret) == 0)
+ {
+ fprintf (stderr, &quot;*** Warning: %s\n&quot;, gnutls_strerror (ret));
+ }
else if (ret &lt; 0)
{
fprintf (stderr, &quot;\n*** Received corrupted &quot;
@@ -325,7 +316,7 @@ main (void)
{
/* echo data back to the client
*/
- gnutls_record_send (session, buffer, strlen (buffer));
+ gnutls_record_send (session, buffer, ret);
}
}
printf (&quot;\n&quot;);