Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > 其他编程语言 > Python HTTPS/SSL Windows How To
【标  题】:Python HTTPS/SSL Windows How To
【关键字】:Python,HTTPS/SSL,Windows,How
【来  源】:http://www.cublog.cn/u/8780/showart.php?id=149458

Python HTTPS/SSL Windows How To

Your Ad Here

HTTPS in the newer versions of Python (2.x and later) is considerably[相当地] easier now. Now it's simply a matter of doing the following:

import httplib
HOSTNAME = 'login.yahoo.com'
conn = httplib.HTTPSConnection(HOSTNAME)
conn.putrequest('GET', '/')
conn.endheaders()
response = conn.getresponse()
print response.read()

For information on how to get SSL working on Windows,check out Simon Willison's page.

 

How to install and setup M2Crypto for the
WinNT environment in three easy steps

M2Crypto will let you retrieve web pages from HTTPS servers. It's great, but it is short on documentation.

Ingredients:

M2Crypto from Ng Pheng Siong. the Windows BINARY package.
OpenSSL

Step 1. Install OpenSSL

Step 1.1 Install OpenSSL DLL files somewhere

This is easy. Just open the the OpenSSL zip file into a directory somewhere on your file system. I put it here:

C:\openssl-0.9.6-win32

It should include these DLLs:

libeay32.dll
ssleay32.dll

Step 1.2 Add the path to the DDLs to system Path environment

Add the directory to your system path. Open "Control Panel | System | Advanced | Environment Variables". Edit the environment variable, Path, to include:

;C:\openssl-0.9.6-win32

Step 2. Install M2Crypto

Step 2.1 Open the m2crypto zip file

Open the zip file m2crypto-0.06-snap6-win32.zip into a package directory m2crypto-0.06-snap6.

Step 2.2 Configure M2Crypto library with Windows specific files.

In the m2crypto-0.06-snap6 package directory find these directories:

M2Crypto/
win/

You need to copy two files from the win directory to the M2Crypto directory. Which files you copy will depend on which version of Python you are using. The win directory will have subdirectories for three versions of Python:

py1/ ......... For Python 1.5.2
py20/ ....... For Python 2.0
py21/ ....... For Python 2.1

Copy all the files from the appropriate directory into the M2Crypto directory.

The M2Crypto directory should now include these files:

_m2crypto.py
_m2cryptoc.dll

Step 2.3 Let Python see the M2Crypto library

This is sort of what would happen if M2Crypto had a distutil (see also the site-module in Python docs). Copy the M2Crypto directory to your Python root directory. For example on my system it would be copied here:

C:\Python21\M2Crypto

Then in your Python root directory create pth file (a text file) called M2Crypto.pth. For example on my system it goes here:

C:\Python21\M2Crypto.pth

The pth file should contain a single line that points to the M2Crypto directory. For example in my pth file it has the following line:

C:\Python21\M2Crypto

Step 3. You're done.

Start up Python and see if it works. From the interpreter type:

import M2Crypto

If this does not return an error then you should be ready to go.

朱镕基传奇身世:乱世孤儿 是朱元璋直系后裔:【上一篇】
一些Python-SSL modules:【下一篇】
【相关文章】
  • Windows Template Library - WTL Version 7.5
  • MySQL 5.0在windows上的安装详细介绍
  • FreeBSD VPN How-To
  • OpenVPN-HOWTO中文版
  • boot windows from the second harddisk
  • The Linux MTD, JFFS HOWTO(中文,未完待续 2006/08/01)
  • Linux与Windows共享建最简Samba
  • Python学习系列之Object and Object-Orientation
  • Python学习系列之异常和文件操作
  • windows下nutch初探
  • 【随机文章】
  • 软件架构师之路
  • QQ聊天病毒之通杀技法(2)
  • 序列号收集
  • NetBSD安装日记
  • 正则表达式之全部符号解释
  • 我们要悼念foxmail了吗?
  • 【转贴】一家之言的经验之谈php+mysql扎实个人基本功
  • Driver development code example.
  • 如何监控和保护Linux下进程安全
  • "Code Red" 蠕虫攻击方式分析
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.