Skip to content

Instantly share code, notes, and snippets.

Working from home

Adi Roiban adiroiban

Working from home
Block or report user

Report or block adiroiban

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
adiroiban /
Last active Oct 10, 2017
Twisted HTTP Connect Proxy
Based on the code from Scrapy
from __future__ import absolute_import, unicode_literals
import re
from urlparse import urlparse
from twisted.internet import defer
adiroiban /
Created Oct 6, 2017
Simple test for pyOpenSSL with SNI
# Copyright (C) Jean-Paul Calderone
# See LICENSE for details.
from sys import argv, stdout
from socket import socket
from OpenSSL.SSL import TLSv1_METHOD, Context, Connection
def test_ssl_client_sni():
adiroiban /
Created Sep 22, 2017
ldaptor LDAP server faking AD UPN BIND
An ldaptor LDAP server which can authenticate based on UPN, as AD does.
The LDAP entry needs to have the `userPrincipalName` attribute set.
from __future__ import absolute_import
from ldaptor import interfaces
from ldaptor.protocols import pureldap
from ldaptor.protocols.ldap import distinguishedname, ldaperrors
View bashrc
# based on the prompt from
function prompt_command {
# Calculate the width of the prompt:
hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
# "whoami" and "pwd" include a trailing newline
adiroiban /
Last active May 19, 2017
pyopenssl SSLContext.set_verify callback for CRL / CDP validation
class CRLValidator(object):
Helper for validating certificates against CRL.
For now it only support a single CRL signed by a single CA.
It provides the `CRLValidator.validate(certificate)` method which can be
used as a callback for `SSLContext.set_verify`.
_random = random
adiroiban / example run
Last active Jan 31, 2019
Persistent pool not closed in Twisted
View example run
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
>>> import cryptography
>>> import OpenSSL
>>> cryptography.__version__
>>> OpenSSL.__version__
adiroiban /
Last active Aug 12, 2016
Twisted support for parsing multipart/form-data POST requests
# Copyright (c) 2014 Adi Roiban.
# See LICENSE for details.
Code for handling data submitted via HTTP form.
We should try to keep this code independent of Chevah project as we plan
to send it upstream in Twisted.
from StringIO import StringIO
adiroiban /
Last active Aug 11, 2016
Client TLS transport connected state out of sync
# Script to demonstrate the Client.transport.connected state
from twisted.internet.protocol import Protocol
from twisted.internet.protocol import Factory
from twisted.internet.endpoints import SSL4ServerEndpoint, TCP4ServerEndpoint
from twisted.internet.endpoints import (
SSL4ClientEndpoint, TCP4ClientEndpoint, connectProtocol)
from twisted.internet import reactor
from twisted.internet.ssl import PrivateCertificate, ClientContextFactory
adiroiban / twisted.diff
Created Jul 19, 2016
pydoctor for twisted no fetch
View twisted.diff
diff --git twisted/python/ twisted/python/
index 76a5458..4d064b4 100644
--- twisted/python/
+++ twisted/python/
@@ -60,6 +60,13 @@ class TwistedSphinxInventory(SphinxInventory):
# as an exceptional case.
# We get the base URL from IInterface which is assume that is
# always and already well defined in the Sphinx index.
+ link = self._links.get('zope.interface.interfaces.IInterface')
You can’t perform that action at this time.