• 在非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. 3226. [SDOI2008]校门外的区间【线段树】

    Description   受校门外的树这道经典问题的启发,A君根据基本的离散数学的知识,抽象出5种运算维护集合S(S初始为空)并最终输出S.现在,请你完成这道校门外的树之难度增强版——校门外的区间. ...

  2. Python自动化之modelform和原生ajax

    modelform验证 `views.py` from django.shortcuts import render,HttpResponse from app01 import models fro ...

  3. 支持xhr浏览器:超时设定、加载事件、进度事件

    各个浏览器虽然都支持xhr,但还是有些差异. 1.超时设定 IE8为xhr对象添加了一个timeout属性,表示请求在等待响应多少毫秒后就终止.再给timeout这只一个数值后,如果在规定的时间内浏览 ...

  4. HDU 6318 Swaps and Inversions 思路很巧妙!!!(转换为树状数组或者归并求解逆序数)

    Swaps and Inversions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  5. Angular动态表单生成(七)

    动态表单生成之拖拽生成表单(上) 这个功能就比较吊炸天了,之前的六篇,都是ng-dynamic-forms自带的功能,可能很多的说明官方的文档都已经写了,我只是个搬运工,而在这篇文章中,我将化身一个工 ...

  6. block本质探寻三之block类型

    一.oc代码 提示:看本文章之前,最好按顺序来看: //代码 void test1() { ; void(^block1)(void) = ^{ NSLog(@"block1----&quo ...

  7. Object C学习笔记12-集合

    这里讲到的集合是指Set集合,其实Array也是一种类型的集合.在Object C中提供了两个集合类NSSet和NSMutableSet.其实NSSet和NSArray性质一样,都是用于存储对象的. ...

  8. 对象关系映射(ORM)

    1.什么是 对象-关系映射 对象-关系映射(Object Relational Mapping,简称ORM,对象关系映射)是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术. 简单的说,OR ...

  9. redis 基本数据类型-列表(List)

    今天不瘦给大家分享一下redis第二个基本数据类型:列表.如果大家了解基本数据结构,相信大家对列表不会陌生,比如在C语言中我们可以使用数组实现一个列表,也可以使用链表实现一个列表(列表链表傻傻分不清楚 ...

  10. 不安分的android开发者(小程序初尝试,前后台都自己做)

    前言 作为一个稍微有点想法的程序员来说,拥有一个自己开发,自己运营,完全属于自己的应用,应该是很多人的梦想.刚毕业那会,自己的工作是做游戏,于是也和朋友业余时间开发一些小游戏玩玩,可是终究不成气候,而 ...