Sophie

Sophie

distrib > Mageia > 6 > armv7hl > by-pkgid > be48589b7b9611719bcc10d42dba172d > files > 82

python-OpenSSL-doc-16.1.0-1.mga6.noarch.rpm



<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Internals &mdash; pyOpenSSL 16.1.0 documentation</title>
  

  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  

  

  
        <link rel="index" title="Index"
              href="genindex.html"/>
        <link rel="search" title="Search" href="search.html"/>
    <link rel="top" title="pyOpenSSL 16.1.0 documentation" href="index.html"/>
        <link rel="next" title="Backward Compatibility" href="backward-compatibility.html"/>
        <link rel="prev" title="SSL — An interface to the SSL-specific parts of OpenSSL" href="api/ssl.html"/> 

  
  <script src="_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="index.html" class="icon icon-home"> pyOpenSSL
          

          
          </a>

          
            
            
              <div class="version">
                16.1.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
                <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html"><code class="docutils literal"><span class="pre">OpenSSL</span></code> &#8212; Python interface to OpenSSL</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Internals</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#exceptions">Exceptions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#callbacks">Callbacks</a></li>
<li class="toctree-l2"><a class="reference internal" href="#accessing-socket-methods">Accessing Socket Methods</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="backward-compatibility.html">Backward Compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="index.html">pyOpenSSL</a>
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          

 



<div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="index.html">Docs</a> &raquo;</li>
      
    <li>Internals</li>
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="_sources/internals.txt" rel="nofollow"> View page source</a>
          
        
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="internals">
<span id="id1"></span><h1>Internals<a class="headerlink" href="#internals" title="Permalink to this headline">¶</a></h1>
<p>We ran into three main problems developing this: Exceptions, callbacks and
accessing socket methods. This is what this chapter is about.</p>
<div class="section" id="exceptions">
<span id="id2"></span><h2>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h2>
<p>We realized early that most of the exceptions would be raised by the I/O
functions of OpenSSL, so it felt natural to mimic OpenSSL&#8217;s error code system,
translating them into Python exceptions. This naturally gives us the exceptions
<a class="reference internal" href="api/ssl.html#OpenSSL.SSL.ZeroReturnError" title="OpenSSL.SSL.ZeroReturnError"><code class="xref py py-exc docutils literal"><span class="pre">SSL.ZeroReturnError</span></code></a>, <a class="reference internal" href="api/ssl.html#OpenSSL.SSL.WantReadError" title="OpenSSL.SSL.WantReadError"><code class="xref py py-exc docutils literal"><span class="pre">SSL.WantReadError</span></code></a>,
<a class="reference internal" href="api/ssl.html#OpenSSL.SSL.WantWriteError" title="OpenSSL.SSL.WantWriteError"><code class="xref py py-exc docutils literal"><span class="pre">SSL.WantWriteError</span></code></a>, <a class="reference internal" href="api/ssl.html#OpenSSL.SSL.WantX509LookupError" title="OpenSSL.SSL.WantX509LookupError"><code class="xref py py-exc docutils literal"><span class="pre">SSL.WantX509LookupError</span></code></a> and
<a class="reference internal" href="api/ssl.html#OpenSSL.SSL.SysCallError" title="OpenSSL.SSL.SysCallError"><code class="xref py py-exc docutils literal"><span class="pre">SSL.SysCallError</span></code></a>.</p>
<p>For more information about this, see section <a class="reference internal" href="api/ssl.html#openssl-ssl"><span class="std std-ref">SSL &#8212; An interface to the SSL-specific parts of OpenSSL</span></a>.</p>
</div>
<div class="section" id="callbacks">
<span id="id3"></span><h2>Callbacks<a class="headerlink" href="#callbacks" title="Permalink to this headline">¶</a></h2>
<p>Callbacks were more of a problem when pyOpenSSL was written in C.
Having switched to being written in Python using cffi, callbacks are now straightforward.
The problems that originally existed no longer do
(if you are interested in the details you can find descriptions of those problems in the version control history for this document).</p>
</div>
<div class="section" id="accessing-socket-methods">
<span id="socket-methods"></span><h2>Accessing Socket Methods<a class="headerlink" href="#accessing-socket-methods" title="Permalink to this headline">¶</a></h2>
<p>We quickly saw the benefit of wrapping socket methods in the
<a class="reference internal" href="api/ssl.html#OpenSSL.SSL.Connection" title="OpenSSL.SSL.Connection"><code class="xref py py-class docutils literal"><span class="pre">SSL.Connection</span></code></a> class, for an easy transition into using SSL. The
problem here is that the <code class="xref py py-mod docutils literal"><span class="pre">socket</span></code> module lacks a C API, and all the
methods are declared static. One approach would be to have <a class="reference internal" href="api.html#module-OpenSSL" title="OpenSSL: Python interface to OpenSSL"><code class="xref py py-mod docutils literal"><span class="pre">OpenSSL</span></code></a> as
a submodule to the <code class="xref py py-mod docutils literal"><span class="pre">socket</span></code> module, placing all the code in
<code class="docutils literal"><span class="pre">socketmodule.c</span></code>, but this is obviously not a good solution, since you
might not want to import tonnes of extra stuff you&#8217;re not going to use when
importing the <code class="xref py py-mod docutils literal"><span class="pre">socket</span></code> module. The other approach is to somehow get a
pointer to the method to be called, either the C function, or a callable Python
object. This is not really a good solution either, since there&#8217;s a lot of
lookups involved.</p>
<p>The way it works is that you have to supply a <code class="xref py py-class docutils literal"><span class="pre">socket</span></code>- <strong>like</strong> transport
object to the <a class="reference internal" href="api/ssl.html#OpenSSL.SSL.Connection" title="OpenSSL.SSL.Connection"><code class="xref py py-class docutils literal"><span class="pre">SSL.Connection</span></code></a>. The only requirement of this object is
that it has a <code class="xref py py-meth docutils literal"><span class="pre">fileno()</span></code> method that returns a file descriptor that&#8217;s
valid at the C level (i.e. you can use the system calls read and write). If you
want to use the <code class="xref py py-meth docutils literal"><span class="pre">connect()</span></code> or <code class="xref py py-meth docutils literal"><span class="pre">accept()</span></code> methods of the
<a class="reference internal" href="api/ssl.html#OpenSSL.SSL.Connection" title="OpenSSL.SSL.Connection"><code class="xref py py-class docutils literal"><span class="pre">SSL.Connection</span></code></a> object, the transport object has to supply such
methods too. Apart from them, any method lookups in the <a class="reference internal" href="api/ssl.html#OpenSSL.SSL.Connection" title="OpenSSL.SSL.Connection"><code class="xref py py-class docutils literal"><span class="pre">SSL.Connection</span></code></a>
object that fail are passed on to the underlying transport object.</p>
<p>Future changes might be to allow Python-level transport objects, that instead
of having <code class="xref py py-meth docutils literal"><span class="pre">fileno()</span></code> methods, have <code class="xref py py-meth docutils literal"><span class="pre">read()</span></code> and <code class="xref py py-meth docutils literal"><span class="pre">write()</span></code>
methods, so more advanced features of Python can be used. This would probably
entail some sort of OpenSSL <strong>BIOs</strong>, but converting Python strings back and
forth is expensive, so this shouldn&#8217;t be used unless necessary. Other nice
things would be to be able to pass in different transport objects for reading
and writing, but then the <code class="xref py py-meth docutils literal"><span class="pre">fileno()</span></code> method of <a class="reference internal" href="api/ssl.html#OpenSSL.SSL.Connection" title="OpenSSL.SSL.Connection"><code class="xref py py-class docutils literal"><span class="pre">SSL.Connection</span></code></a>
becomes virtually useless. Also, should the method resolution be used on the
read-transport or the write-transport?</p>
</div>
</div>


           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="backward-compatibility.html" class="btn btn-neutral float-right" title="Backward Compatibility" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="api/ssl.html" class="btn btn-neutral" title="SSL — An interface to the SSL-specific parts of OpenSSL" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2001-2017, The pyOpenSSL developers.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'./',
            VERSION:'16.1.0',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true
        };
    </script>
      <script type="text/javascript" src="_static/jquery.js"></script>
      <script type="text/javascript" src="_static/underscore.js"></script>
      <script type="text/javascript" src="_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>