fatal: unable to access '': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

展开阅读全文

openssl客户端连接过程:SSL_connect(ssl);返回0

01-13

目的基于openssl实现客户端远程连接 下面是部分接口代码 ``` SSL_library_init(); OpenSSL_add_all_algorithms(); SSL_load_error_strings(); ctx = SSL_CTX_new(SSLv2_client_method()); if (ctx == NULL) { ERR_print_errors_fp(stdout); exit(1); } if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("Socket"); exit(errno); } printf("socket created\n"); memset (&dest, '\0', sizeof(dest)); dest.sin_family = AF_INET; dest.sin_port = htons(atoi(argv[2])); if (inet_aton(argv[1], (struct in_addr *) &dest.sin_addr.s_addr) == 0) { perror(argv[1]); exit(errno); } printf("address created\n"); if (connect(sockfd, (struct sockaddr *) &dest, sizeof(dest)) != 0) { perror("Connect "); exit(errno); } printf("server connected\n"); ssl = SSL_new(ctx); if(!SSL_CTX_load_verify_locations(ctx, "/root/.ssh/ca-chain.cert.pem", NULL)){ ERR_print_errors_fp(stderr); return 1; } if (SSL_CTX_use_PrivateKey_file(ctx, "/root/.ssh/client.key.pem", SSL_FILETYPE_PEM) <= 0){ SSL_CTX_free (ctx); ERR_print_errors_fp(stderr); return 1; } if(!SSL_CTX_use_certificate_file(ctx, "/root/.ssh/client.cert.pem", SSL_FILETYPE_PEM)){ fprintf (stderr, "SSL_CTX_use_certificate_file ERROR\n"); ERR_print_errors_fp(stderr); return EXIT_FAILURE; } if (!SSL_CTX_check_private_key(ctx)) { ERR_print_errors_fp(stdout); exit(1); } if(SSL_get_verify_result(ssl) != X509_V_OK){ printf("X509证书无效\n"); return false; } SSL_set_fd(ssl, sockfd); if ((t=SSL_connect(ssl)) <= 0){ //返回0 ERR_print_errors_fp(stderr); } else { printf("Connected with %s encryption\n", SSL_get_cipher(ssl)); ShowCerts(ssl); } ``` 服务端打印出的Bug: routines:REQUEST_CERTIFICATE:peer error no certificate:s2_pkt.c:681: 是不是本地证书加载未成功?求指点。。。。 问答

OpenSSL SSL_connect:与api.amazonalexa.com相关的SSL_ERROR_SYSCALL:443

09-25

<div class="post-text" itemprop="text"> <p>I've been trying to get the Skill Management API working and this morning I've hit a new roadblock without haven't changed anything. I was getting a "User has not consented to this operation error last night" and without changing anything this morning, this is the curl log I'm getting:</p> <p>Trying to hit the API with the same code as last night and now I'm getting:</p> <pre><code>string(513) " * Hostname api.amazonalexa.com was found in DNS cache * Trying 54.239.28.187... * TCP_NODELAY set * Connected to api.amazonalexa.com (54.239.28.187) port 443 (#0) * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to api.amazonalexa.com:443 * stopped the pause stream! * Closing connection 0 " </code></pre> <p>Here is the code I'm using:</p> <pre><code>ob_start(); $out = fopen('php://output', 'w'); // exchange the access token for list of skills $c = curl_init('https://api.amazonalexa.com/v0/skills/'); curl_setopt($c, CURLOPT_HTTPHEADER, array( 'Authorization: ' . $access_token, 'Accept: application/json', 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' )); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($c, CURLOPT_VERBOSE, true); curl_setopt($c, CURLOPT_STDERR, $out); curl_setopt($c, CURLOPT_POST, 1); $r = curl_exec($c); curl_close($c); fclose($out); $debug = ob_get_clean(); var_dump($r); echo "<BR><BR>"; var_dump($debug); $d = json_decode($r); </code></pre> <p>$r in this case produces bool(false) and $d outputs NULL. I host my server on Godaddy if that makes a difference. I am still able to access Login with Amazon and retrieve an access token. So, it doesn't seem like a hosting problem.</p> </div> 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览