salt-api https连接问题
- 在非salt-api的主机上测试api连通性,测试代码如下:
#!/usr/bin/env python
import pycurl
import StringIO
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
def api_login():
global token
url = 'https://10.10.32.102:8000/login'
ch = pycurl.Curl()
ch.setopt(ch.URL, url)
info = StringIO.StringIO()
ch.setopt(ch.WRITEFUNCTION, info.write)
ch.setopt(ch.POST, True)
ch.setopt(ch.SSL_VERIFYPEER, 0)
ch.setopt(ch.SSL_VERIFYHOST, 2)
ch.setopt(ch.HTTPHEADER, ['Accept: application/x-yaml'])
ch.setopt(ch.POSTFIELDS, 'username=%s&password=%s&eauth=pam' %('kbson', 'kbson'))
#ch.setopt(ch.HEADER, True)
ch.setopt(ch.HEADER,False)
ch.perform()
print ch
html = info.getvalue()
print "bbbxxxx!!"
token = html.split("\n")[-3].replace("\n", '')
token = token.split(' ')[3]
print token
info.close()
ch.close()
if __name__ == '__main__':
api_login()
- 报错:
Traceback (most recent call last):
File "salt_api.py", line 36, in <module>
api_login()
File "salt_api.py", line 24, in api_login
ch.perform()
pycurl.error: (51, "SSL: certificate subject name 'localhost' does not match target host name 'localdomain'")
- 方法一:
把测试的代码迁移到salt-api所在的机器,因为本地有认证需要的证书,
When you post to (or access in any way) a https url, the SSL/TLS process starts with the server giving the client a certificate. The client expects the name in the certificate to be identical to the server name in the URL.
In your case, you've installed a self-signed certificate. When you created a certificate signing request (CSR) with OpenSSL, you didn't specify a host name ('subject' in certificate-speak), so OpenSSL tied to autodetect the hostname. It found "localhost.localdomain", which is unfortunate, since that is a name that is used on all systems to reference the system itself. A proper domain name would have been better, but that's not the reason you're getting an SSL error.
The error message appears because you're accessing the https page using an IP address (https://xx.xx.xx.xx/someurl), not the host name (https://localhost.localdomain/someurl). Since the certificate wasn't (and cannot be) issued to an IP address, SSL negotiation fails.
Try using "localhost.localdomain" instead of the IP address. (And if that works, consider generating a new certificate issued to a proper hostname.)
- 方法二:
在非salt-api所在机器上部署,需要作如下操作:
pip install PyOpenSSL
否则会报错:
'tls' __virtual__ returned False: PyOpenSSL version 0.10 or later must be installed before this module can be used.
生成证书:
(fourthgen) [root@test107 fourthgen]# salt-call tls.create_self_signed_cert
local:
Certificate "localhost" already exists
证书路径在:
/etc/pki/tls/certs/localhost.crt
/etc/pki/tls/private/localhost.key
拷贝证书:
cp /etc/pki/tls/certs/localhost.crt /etc/pki/tls/private/
修改/etc/hosts,添加:
10.10.32.102 localhost
,将salt-api url改成“https://localhost:8000/login”
salt-api https连接问题的更多相关文章
- https连接的前几毫秒发生了什么
在讨论这个话题之前,先提几个问题: 为什么说https是安全的,安全在哪里? https是使用了证书保证它的安全的么? 为什么证书需要购买? 我们先来看https要解决什么问题 (手机读者推荐移步ht ...
- Python中HTTPS连接
permike 原文 Python中HTTPS连接 今天写代码时碰到一个问题,花了几个小时的时间google, 首先需要安装openssl,更新到最新版本后,在浏览器里看是否可访问,如果是可以的,所以 ...
- CentOS 安装及配置Salt api
安装 # yum -y install salt-api 更改配置 vim /etc/salt/master 把默认的注释掉 我们这边默认配置文件目录是/srv/salt default_inclu ...
- java ssl https 连接详解 生成证书 tomcat keystone
java ssl https 连接详解 生成证书 我们先来了解一下什么理HTTPS 1. HTTPS概念 1)简介 HTTPS(全称:Hypertext Transfer Protocol over ...
- 死磕salt系列-salt API 使用
启用salt-api 服务 这里简单的说明下,SaltStack官方支持三种REST API,分别是rest_cherry; rest_tonado和rest_wsgi, 本文选择使用rest_che ...
- file_get_contents无法请求https连接的解决方法 php开启curl
file_get_contents无法请求https连接的解决方法 方法1: PHP.ini默认配置下,用file_get_contents读取https的链接,就会如下错误: Warning: fo ...
- CAS环境搭建-证书方式(https连接)
一.教程前言 1 教程目的:从头到尾细细道来单点登录服务器及客户端应用的每个步骤 2 单点登录(SSO):请看<CAS简介> 3 本教程使用的SSO服务器是Yelu大学研发的CAS(Cen ...
- tomcat7.0.55配置单向和双向HTTPS连接(二)
上一篇文章:tomcat7.0.55配置单向和双向HTTPS连接 只是简要的配置了一下HTTPS,还有许多问题没有解决,本篇来解决这些文件 首先按照这篇文章:Widows下利用OpenSSL生成证书来 ...
- tomcat7.0.55配置单向和双向HTTPS连接
HTTPS配置中分为单向连接和双向连接,单向连接只需要服务器安装证书,客户端不需要,双向连接需要服务器和客户端都安装证书 下面的配置都没有用CA签名来配置,都不能用于生产环境,实际配置中是需要CA的, ...
- 浅谈HTTPS连接
相信很多朋友都遇到过网页被强插广告的情况,好端端一个干净的页面,动不动就被插了个屠龙宝刀点击就送的小窗口,看着就心烦.这种网页劫持强插广告的现象,在中国非常常见,往往是运营商进行HTTP劫持所造成的. ...
随机推荐
- 起床困难综合症 NOI_2014_D1T1
这道题的正解其实没什么好说的,反而是部分分设计非常巧妙. 之所以要单开一篇是因为当时机房的部分同学刚学位运算,我拿这个题去讲想毒瘤大家一下,于是做了一个挺好看的课件. ppt -> pdf -& ...
- App性能测试-GT
无意之间发现了GT(随身调)这个性能测试工具,该工具是由腾讯出品的开源测试工具,直接运行在手机上的“集成调测环境”. 1.下载:下载地址:开源地址:https://github.com/Tencent ...
- http_load安装和使用
一.安装 wget http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gz tar zxvf http_load-12mar20 ...
- Mac生成APP图标和启动图的脚本
概述 之前用的一个批量导出APP图标和启动图的软件,今天发现收费了,于是自己造了个简单的轮子. 实现 Mac上的sips命令,可以很方便的帮助用户修改图片尺寸 Xcode里面的APP启动图资源包含两部 ...
- Python自动化之复习基础
用户在命令行输入的参数可以在sys.argv里面看到,并且是以列表的形式现实的
- JDK(九)JDK1.7源码分析【集合】HashMap的死循环
前言 在JDK1.7&1.8源码对比分析[集合]HashMap中我们遗留了一个问题:为什么HashMap在调用resize() 方法时会出现死循环?这篇文章就通过JDK1.7的源码来分析并解释 ...
- 让自己的项目支持 Carthage
据说 cocoaPods 升级到1.0之后变得使用起来不太方便了,好吧,这段时间公司事儿比较多而且是自己写的sdk就不怎么写demo了,cocoaPods也没用几次…… 前两天朋友说要转战 Carth ...
- 用ansible2.5在Centos7.2上部署OpenShift3.9(转)
1.环境: 主机名 ip 角色 master 10.2.1.198 master node1 10.2.1.174 no ...
- Java开发工程师基础Math,Random,Scanner类的使用
Math类的使用(重点) (1)数学操作类:该类没有构造函数,方法均为静态的 (2)掌握内容 A:成员变量 **E:比任何其他值都更接近e(即自然对数的底数)的double值. **PI:比任何其他值 ...
- Linux下onvif客户端获取ipc摄像头 GetServices:获取媒体地址(有的h265摄像头必须要这个接口)
GetServices:获取媒体地址(有些h265的摄像头必须用到这个接口,得到获取能力时没获取到的另一个媒体地址) 鉴权:但是在使用这个接口之前是需要鉴权的.ONVIF协议规定,部分接口需要鉴权,部 ...