栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

如何在Python应用程序中安装和使用OpenSSL库?

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Python应用程序中安装和使用OpenSSL库?

OpenSSL is popular security library used by a lot of products, applications, vendors. OpenSSL provides libraries for the most of the programming languages. Python is popular programming language too. We can use OpenSSL library in Python applications. In this tutorial we will develop an example application that uses OpenSSL Python Library and bindings.

OpenSSL是许多产品,应用程序,供应商使用的流行安全性库。 OpenSSL提供了大多数编程语言的库。 Python也是流行的编程语言。 我们可以在Python应用程序中使用OpenSSL库。 在本教程中,我们将开发一个使用OpenSSL Python库和绑定的示例应用程序。

使用Pip安装OpenSSL Python库 (Install OpenSSL Python Library with Pip)

We can use pip install for all Linux distributions like Ubuntu, Debian, Mint, Kali, Fedora, CentOS, RedHat, etc. . We can also install OpenSSL Python Library in Windows Operating systems Windows 7, Windows 8, Windows 10, Windows Server 2008, Windows Server 2012, Windows Server 2016.

我们可以对所有Linux发行版使用pip install,例如Ubuntu,Debian,Mint,Kali,Fedora,CentOS,RedHat等。 我们还可以在Windows操作系统Windows 7,Windows 8,Windows 10,Windows Server 2008,Windows Server 2012,Windows Server 2016中安装OpenSSL Python库。

$ pip install pyopenssl
Install OpenSSL Python Lıbrary with Pip
使用Pip安装OpenSSL Python库
使用Ubuntu,Debian,Mint,Kali安装OpenSSL Python库(Install OpenSSL Python Library with Ubuntu, Debian, Mint, Kali)

We can install OpenSSL python library for deb or apt based distributions like below.

我们可以为基于deb或apt的发行版安装OpenSSL python库,如下所示。

$ apt install python3-openssl
为CentOS,Fedora,RedHat安装OpenSSL Python库 (Install OpenSSL Python Lıbrary For CentOS, Fedora, RedHat)

We can install OpenSSL python libraries for rpm or yum or dnf based distributions like below.

我们可以为基于rpm或yum或dnf的发行版安装OpenSSL python库,如下所示。

$ yum install python3-pyOpenSSL.noarch
导入OpenSSL (Import OpenSSL)

In order to use OpenSSL library in our Python application we should import the OpenSSL library with the import keyword like below.

为了在我们的Python应用程序中使用OpenSSL库,我们应该使用import关键字导入OpenSSL库,如下所示。

from OpenSSL import SSL
打印OpenSSL库版本 (Print OpenSSL Library Version)

In this example we will print SSL Certificate Paths. SSL Certificate Paths are stored in the attribute _CERTIFICATE_PATH_LOCATIONS . We will name the python application as testopenssl.py and put the following code.

在此示例中,我们将打印SSL证书路径。 SSL证书路径存储在属性_CERTIFICATE_PATH_LOCATIONS 。 我们将python应用程序命名为testopenssl.py并放置以下代码。

from OpenSSL import SSL 
 
print SSL._CERTIFICATE_PATH_LOCATIONS

We run our python application like below.

我们如下运行python应用程序。

$ python testopenssl.py
Print OpenSSL Library Version
打印OpenSSL库版本
LEARN MORE  How To Generate Random Numbers In Linux? 了解更多如何在Linux中生成随机数?

翻译自: https://www.poftut.com/install-use-openssl-library-python-applications/

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/833906.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号