~ubuntu-branches/debian/experimental/apt-cacher-ng/experimental

« back to all changes in this revision

Viewing changes to test/build/HAVE_SSL.cc

  • Committer: Package Import Robot
  • Author(s): Eduard Bloch
  • Date: 2015-06-18 22:28:00 UTC
  • mfrom: (1.7.5) (29.1.59 sid)
  • Revision ID: package-import@ubuntu.com-20150618222800-81vrtqn93nma6l87
Tags: 0.8.4-1
* New upstream version
  + Fixes creation of pidfile even in foreground mode (closes: #784752)
* Added pt_BR.po update (by Adriano Rafael Gomes, closes: #785471)
* Getting rid of "ed" recommendation, new version brings a faster
  replacement (closes: #772529)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <openssl/bio.h>
 
2
#include <openssl/ssl.h>
 
3
#include <openssl/err.h>
 
4
 
 
5
// crudely stripped down acng code just for testing purposes
 
6
int main()
 
7
{
 
8
 
 
9
SSL * ssl(NULL);
 
10
SSL_CTX *m_ctx(0);
 
11
BIO *m_bio(0);
 
12
        int hret(0);
 
13
        if(!m_ctx)
 
14
        {
 
15
                m_ctx = SSL_CTX_new(SSLv23_client_method());
 
16
                if(!m_ctx)
 
17
                        goto ssl_init_fail;
 
18
 
 
19
        }
 
20
 
 
21
        ssl = SSL_new(m_ctx);
 
22
        if(!ssl)
 
23
                goto ssl_init_fail;
 
24
 
 
25
        SSL_set_connect_state(ssl);
 
26
        SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY
 
27
                        | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
 
28
                        | SSL_MODE_ENABLE_PARTIAL_WRITE);
 
29
 
 
30
        if((hret=SSL_set_fd(ssl, hret)) != 1)
 
31
                goto ssl_init_fail_retcode;
 
32
        if((hret=SSL_connect(ssl)) != 1)
 
33
                goto ssl_init_fail_retcode;
 
34
 
 
35
        m_bio = BIO_new(BIO_f_ssl());
 
36
        BIO_set_ssl(m_bio, ssl, BIO_NOCLOSE);
 
37
 
 
38
        BIO_set_nbio(m_bio, 1);
 
39
 
 
40
        hret=SSL_get_verify_result(ssl);
 
41
        if( hret != X509_V_OK)
 
42
                goto ssl_init_fail;
 
43
 
 
44
        return true;
 
45
 
 
46
        ssl_init_fail_retcode:
 
47
        ssl_init_fail:
 
48
        return false;
 
49
}