Minor changes of error messages in caNl examples
authorMarcel Poul <marcel.poul@cern.ch>
Thu, 15 Nov 2012 16:32:46 +0000 (16:32 +0000)
committerMarcel Poul <marcel.poul@cern.ch>
Thu, 15 Nov 2012 16:32:46 +0000 (16:32 +0000)
emi.canl.canl-c/examples/canl_sample_client.c
emi.canl.canl-c/examples/canl_sample_server.c
emi.canl.canl-c/src/canl_cert.c

index 60c1bbf..9bac30b 100644 (file)
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
 
     err = canl_create_io_handler(my_ctx, &my_io_h);
     if (err) {
-        printf("io handler cannot be created: %s\n",
+        printf("io handler cannot be created:\n[CANL] %s\n",
                 canl_get_error_message(my_ctx));
         goto end;
     }
@@ -87,7 +87,8 @@ int main(int argc, char *argv[])
         err = canl_ctx_set_ssl_cred(my_ctx, serv_cert, serv_key, proxy_cert,
                                      NULL, NULL);
         if (err) {
-            printf("[CLIENT] cannot set certificate or key to context: %s\n",
+            printf("[CLIENT] cannot set certificate or key" 
+                   " to context:\n[CANL] %s\n",
                     canl_get_error_message(my_ctx));
             goto end;
         }
@@ -96,7 +97,7 @@ int main(int argc, char *argv[])
     err = canl_io_connect(my_ctx, my_io_h, p_server, NULL, port, NULL, 0,
             NULL, &timeout);
     if (err) {
-        printf("[CLIENT] connection to %s cannot be established: %s\n",
+        printf("[CLIENT] connection to %s cannot be established:\n[CANL] %s\n",
               p_server, canl_get_error_message(my_ctx));
         goto end;
     }
@@ -110,7 +111,7 @@ int main(int argc, char *argv[])
     printf("[CLIENT] Trying to send sth to the server\n");
     err = canl_io_write (my_ctx, my_io_h, buf, buf_len, &timeout);
     if (err <= 0) {
-        printf("can't write using ssl: %s\n",
+        printf("can't write using ssl:\n[CANL] %s\n",
               canl_get_error_message(my_ctx));
         goto end;
     }
index a421698..d129c4b 100644 (file)
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
 
     err = canl_create_io_handler(my_ctx, &my_io_h);
     if (err) {
-        printf("[SERVER] io handler cannot be created: %s\n",
+        printf("[SERVER] io handler cannot be created:\n[CANL] %s\n",
               canl_get_error_message(my_ctx));
         goto end;
     }
@@ -79,7 +79,8 @@ int main(int argc, char *argv[])
        err = canl_ctx_set_ssl_cred(my_ctx, serv_cert, serv_key, NULL, 
                                     NULL, NULL);
         if (err) {
-            printf("[SERVER] cannot set certificate or key to context: %s\n",
+            printf("[SERVER] cannot set certificate or key to"
+                   " context:\n[CANL] %s\n",
                   canl_get_error_message(my_ctx));
             goto end;
         }
@@ -153,7 +154,7 @@ int main(int argc, char *argv[])
     /* TODO timeout in this function? and select around it*/
     err = canl_io_accept(my_ctx, my_io_h, new_fd, s_addr, 0, &princ, &timeout);
     if (err) {
-        printf("[SERVER] connection cannot be established: %s\n",
+        printf("[SERVER] connection cannot be established:\n[CANL] %s\n",
               canl_get_error_message(my_ctx));
         goto end;
     }
@@ -169,7 +170,7 @@ int main(int argc, char *argv[])
     printf("[SERVER] Trying to send sth to the client\n");
     err = canl_io_write (my_ctx, my_io_h, buf, buf_len, &timeout);
     if (err <= 0) {
-        printf("[SERVER] cannot send message to the client: %s\n",
+        printf("[SERVER] cannot send message to the client:\n[CANL] %s\n",
               canl_get_error_message(my_ctx));
         goto end;
     }
@@ -181,7 +182,7 @@ int main(int argc, char *argv[])
     buf[0] = '\0';
     err = canl_io_read (my_ctx, my_io_h, buf, sizeof(buf)-1, &timeout);
     if (err <= 0) {
-       printf("[SERVER] Failed to receive reply from client: %s\n",
+       printf("[SERVER] Failed to receive reply from client:\n[CANL] %s\n",
               canl_get_error_message(my_ctx));
        goto end;
     }
index 867f096..dbdd2c3 100644 (file)
@@ -115,7 +115,8 @@ int set_key_file(glb_ctx *cc, EVP_PKEY **to, const char *key)
     *to = PEM_read_PrivateKey(key_file, NULL, NULL, NULL);
     if (!(*to)) {
         ssl_err = ERR_peek_error();
-        err = set_error(cc, ssl_err, SSL_ERROR, "error while writing key to context");
+        err = set_error(cc, ssl_err, SSL_ERROR, "Cannot read the key "
+                "from the file");
         goto end;
     }
     if (fclose(key_file)){
@@ -196,7 +197,7 @@ int set_cert_chain_file(glb_ctx *cc, STACK_OF(X509) **to, const char *file)
     cert_file = fopen(file, "rb");
     if (!cert_file)
         return set_error(cc, errno, POSIX_ERROR, "Cannot "
-                "open file with cert. chain");
+                "open the file with the cert. chain");
 
     for (;;)
     {
@@ -213,8 +214,8 @@ int set_cert_chain_file(glb_ctx *cc, STACK_OF(X509) **to, const char *file)
                     break;
                 }
                 else {
-                    ret = set_error(cc, ssl_err, SSL_ERROR, "Cannot get"
-                            "certificate out of file");
+                    ret = set_error(cc, ssl_err, SSL_ERROR, "Cannot read"
+                            " the certificate from the file");
                     goto end;
                 }
             }