• 在非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连接问题的更多相关文章

  1. https连接的前几毫秒发生了什么

    在讨论这个话题之前,先提几个问题: 为什么说https是安全的,安全在哪里? https是使用了证书保证它的安全的么? 为什么证书需要购买? 我们先来看https要解决什么问题 (手机读者推荐移步ht ...

  2. Python中HTTPS连接

    permike 原文 Python中HTTPS连接 今天写代码时碰到一个问题,花了几个小时的时间google, 首先需要安装openssl,更新到最新版本后,在浏览器里看是否可访问,如果是可以的,所以 ...

  3. CentOS 安装及配置Salt api

    安装 # yum -y install salt-api 更改配置 vim /etc/salt/master 把默认的注释掉  我们这边默认配置文件目录是/srv/salt default_inclu ...

  4. java ssl https 连接详解 生成证书 tomcat keystone

    java ssl https 连接详解 生成证书 我们先来了解一下什么理HTTPS 1. HTTPS概念 1)简介 HTTPS(全称:Hypertext Transfer Protocol over ...

  5. 死磕salt系列-salt API 使用

    启用salt-api 服务 这里简单的说明下,SaltStack官方支持三种REST API,分别是rest_cherry; rest_tonado和rest_wsgi, 本文选择使用rest_che ...

  6. file_get_contents无法请求https连接的解决方法 php开启curl

    file_get_contents无法请求https连接的解决方法 方法1: PHP.ini默认配置下,用file_get_contents读取https的链接,就会如下错误: Warning: fo ...

  7. CAS环境搭建-证书方式(https连接)

    一.教程前言 1 教程目的:从头到尾细细道来单点登录服务器及客户端应用的每个步骤 2 单点登录(SSO):请看<CAS简介> 3 本教程使用的SSO服务器是Yelu大学研发的CAS(Cen ...

  8. tomcat7.0.55配置单向和双向HTTPS连接(二)

    上一篇文章:tomcat7.0.55配置单向和双向HTTPS连接 只是简要的配置了一下HTTPS,还有许多问题没有解决,本篇来解决这些文件 首先按照这篇文章:Widows下利用OpenSSL生成证书来 ...

  9. tomcat7.0.55配置单向和双向HTTPS连接

    HTTPS配置中分为单向连接和双向连接,单向连接只需要服务器安装证书,客户端不需要,双向连接需要服务器和客户端都安装证书 下面的配置都没有用CA签名来配置,都不能用于生产环境,实际配置中是需要CA的, ...

  10. 浅谈HTTPS连接

    相信很多朋友都遇到过网页被强插广告的情况,好端端一个干净的页面,动不动就被插了个屠龙宝刀点击就送的小窗口,看着就心烦.这种网页劫持强插广告的现象,在中国非常常见,往往是运营商进行HTTP劫持所造成的. ...

随机推荐

  1. 1898: [Zjoi2005]Swamp 沼泽鳄鱼

    1898: [Zjoi2005]Swamp 沼泽鳄鱼 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1582 Solved: 870 [Submit][S ...

  2. 安装MySQL-python

    安装MySQL-python 1. yum -y install mysql  mysql-devel 2. yum -y install python-devel 3. pip install -i ...

  3. virtualbox+vagrant学习-4-Vagrantfile-4-Tips & Tricks

    Tips & Tricks Vagrantfile是一种非常灵活的配置格式.因为它只是Ruby,所以你可以用它做很多事情.然而,同样的道理,因为它是Ruby,所以有很多方法可以朝自己的脚开枪( ...

  4. VMware 虚拟机安装

    虚拟机下载 VMware官网地址:https://www.vmware.com/ 进行官网后,点击左边的下载图标,然后 作系统选择合适的产品,在这里以Windows系统为例,点击转至下载,如下图所示. ...

  5. Jmeter之post上传文件

    上周五东西都收拾好了,然后被叫住加班,直接搞到凌晨一两点,原因是另一个项目的性能出了点问题.为此我抓包写了一下主业务流的接口,涉及到文件上传,记录一下吧. 一.创建线程组,添加各类组件 这个就不用说了 ...

  6. 转载: 国内的go get无法连接问题的解决

    转载自CSDN的文章 https://blog.csdn.net/gongpulin/article/details/80972806 国内的go get问题的解决 go get golang.org ...

  7. 目标反射回波检测算法及其FPGA实现(准备篇): 用Verilog-HDL状态机控制硬件接口

    基于FPGA的目标反射回波检测算法及其实现(准备篇) :用Verilog-HDL状态机控制硬件接口 前段时间,开发了一个简单的目标反射回波信号识别算法,我会分几篇文章分享这个基于FPGA的回波识别算法 ...

  8. 接口与协议学习笔记-AMBA片上通信协议_APB_AHB_AXI_AXI4不同版本(二)

    随着深亚微米工艺技术日益成熟,集成电路芯片的规模越来越大.数字IC从基于时序驱动的设计方法,发展到基于IP复用的设计方法,并在SOC设计中得到了广泛应用.在基于IP复用的SoC设计中,片上总线设计是最 ...

  9. npm i --save-dev prettier安装警告saveError enoent

    出现问题的情况: 或者: D:\Program Files\nodejs>npm i --save-dev prettier npm WARN saveError ENOENT: no such ...

  10. # 2017-2018-1 20155224 加分项-实现mypwd

    2017-2018-1 20155224 加分项-实现mypwd 1. 学习pwd命令 pwd命令以绝对路径的方式显示用户当前工作目录.命令将当前目录的全路径名称(从根目录)写入标准输出.全部目录使用 ...