Exemple #1
0
Fichier : m2.py Projet : clones/kaa
 def close(self, immediate=False, expected=True):
     if not immediate and self._tls_started:
         # Send (or rather queue for write) an SSL shutdown message to the
         # client to gracefully terminate the session.
         m2.ssl_shutdown(self._ssl.obj)
         super(M2TLSSocket, self).write(self._encrypt())
     return super(M2TLSSocket, self).close(immediate, expected)
Exemple #2
0
 def close(self, immediate=False, expected=True):
     if not immediate and self._tls_started:
         # Send (or rather queue for write) an SSL shutdown message to the
         # client to gracefully terminate the session.
         m2.ssl_shutdown(self._ssl.obj)
         super(M2TLSSocket, self).write(self._encrypt())
     return super(M2TLSSocket, self).close(immediate, expected)
Exemple #3
0
 def close(self, freeBio=False):
     """
        if freeBio is true, call _free_bio
     """
     # type: () -> None
     m2.ssl_shutdown(self.ssl)
     if freeBio:
         self._free_bio()
Exemple #4
0
def c_style(HOST, PORT, req):

    # Set up SSL context.
    ctx = m2.ssl_ctx_new(m2.sslv3_method())
    m2.ssl_ctx_use_cert(ctx, 'client.pem')
    m2.ssl_ctx_use_privkey(ctx, 'client.pem')

    # Make the socket connection.
    s = socket(AF_INET, SOCK_STREAM)
    s.connect((HOST, PORT))

    # Set up the SSL connection.
    sbio = m2.bio_new_socket(s.fileno(), 0)
    ssl = m2.ssl_new(ctx)
    m2.ssl_set_bio(ssl, sbio, sbio)
    m2.ssl_connect(ssl)
    sslbio = m2.bio_new(m2.bio_f_ssl())
    m2.bio_set_ssl(sslbio, ssl, 0)

    # Push a buffering BIO over the SSL BIO.
    iobuf = m2.bio_new(m2.bio_f_buffer())
    topbio = m2.bio_push(iobuf, sslbio)

    # Send the request.
    m2.bio_write(sslbio, req)

    # Receive the response.
    while 1:
        data = m2.bio_gets(topbio, 4096)
        if not data: break
        sys.stdout.write(data)

    # Cleanup. May be missing some necessary steps. ;-|
    m2.bio_pop(topbio)
    m2.bio_free(iobuf)
    m2.ssl_shutdown(ssl)
    m2.ssl_free(ssl)
    m2.ssl_ctx_free(ctx)
    s.close()
Exemple #5
0
def c_style(HOST, PORT, req):

    # Set up SSL context.
    ctx = m2.ssl_ctx_new(m2.sslv3_method())
    m2.ssl_ctx_use_cert(ctx, 'client.pem')
    m2.ssl_ctx_use_privkey(ctx, 'client.pem')

    # Make the socket connection.
    s = socket(AF_INET, SOCK_STREAM)
    s.connect((HOST, PORT))

    # Set up the SSL connection.
    sbio = m2.bio_new_socket(s.fileno(), 0)
    ssl = m2.ssl_new(ctx)
    m2.ssl_set_bio(ssl, sbio, sbio)
    m2.ssl_connect(ssl)
    sslbio = m2.bio_new(m2.bio_f_ssl())
    m2.bio_set_ssl(sslbio, ssl, 0)

    # Push a buffering BIO over the SSL BIO.
    iobuf = m2.bio_new(m2.bio_f_buffer())
    topbio = m2.bio_push(iobuf, sslbio)

    # Send the request.
    m2.bio_write(sslbio, req)

    # Receive the response.
    while 1:
        data = m2.bio_gets(topbio, 4096)
        if not data: break
        sys.stdout.write(data)

    # Cleanup. May be missing some necessary steps. ;-|
    m2.bio_pop(topbio)
    m2.bio_free(iobuf)
    m2.ssl_shutdown(ssl)
    m2.ssl_free(ssl)
    m2.ssl_ctx_free(ctx)
    s.close()
Exemple #6
0
 def close(self):
     # type: () -> None
     m2.ssl_shutdown(self.ssl)
Exemple #7
0
 def close(self):
     m2.ssl_shutdown(self.ssl)
Exemple #8
0
 def close(self):
     m2.ssl_shutdown(self.ssl)
Exemple #9
0
 def close(self):
     # type: () -> None
     m2.ssl_shutdown(self.ssl)