由于某些SSL错误,新服务器无法从Puppetmaster获取配置


14

生产环境中的三台机器存在一些硬件问题,已经退役。基础架构团队已重新安装它们,并为它们提供了相同的主机名和IP地址。目的是在这些系统上运行Puppet,以便可以再次调试它们。


尝试

1)通过发出以下命令,从Puppetmaster中删除了旧的Puppet证书:

puppet cert revoke grb16.company.com
puppet cert clean grb16.company.com

2)删除旧证书后,通过从重新安装的节点之一发出以下命令来创建新的证书请求:

[root@grb16 ~]# puppet agent -t
Info: csr_attributes file loading from /etc/puppet/csr_attributes.yaml
Info: Creating a new SSL certificate request for grb16.company.com
Info: Certificate Request fingerprint (SHA256): 6F:2D:1D:71:67:18:99:86:2C:22:A1:14:80:55:34:35:FD:20:88:1F:36:ED:A7:7B:2A:12:09:4D:F8:EC:BF:6D
Exiting; no certificate found and waitforcert is disabled
[root@grb16 ~]#

3)一旦证书请求在Puppetmaster上可见,就会发出以下命令来对证书请求进行签名:

[root@foreman ~]# puppet cert sign grb16.company.com
Notice: Signed certificate request for grb16.company.com
Notice: Removing file Puppet::SSL::CertificateRequest grb16.company.com at '/var/lib/puppet/ssl/ca/requests/grb16.company.com.pem'
[root@foreman ~]# 

问题

签署证书申请并启动木偶运行后,将引发以下错误:

[root@grb16 ~]# puppet agent -t
Info: Caching certificate for grb16.company.com
Error: Could not request certificate: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Exiting; failed to retrieve certificate and waitforcert is disabled
[root@grb16 ~]# 

第二次运行Puppet将导致:

[root@grb16 ~]# puppet agent -t
Warning: Unable to fetch my node definition, but the agent run will continue:
Warning: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Info: Retrieving pluginfacts
Error: /File[/var/lib/puppet/facts.d]: Failed to generate additional resources using 'eval_generate': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Error: /File[/var/lib/puppet/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet://foreman.company.com/pluginfacts: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Wrapped exception:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Info: Retrieving plugin
Error: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve file metadata for puppet://foreman.company.com/plugins: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Wrapped exception:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Error: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Error: Could not send report: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [CRL is not yet valid for /CN=Puppet CA: foreman.company.com]
[root@grb16 ~]# 

分析

为了解决该问题,对错误消息进行了调查,看起来该问题与SSL或Puppet有关。这些软件包之一可能安装不正确,或者在重新安装的节点上安装了错误的版本。

木偶

[root@grb16 ~]# yum list installed |grep puppet
facter.x86_64          1:2.3.0-1.el6    @puppetlabs_6_products                  
hiera.noarch           1.3.4-1.el6      @puppetlabs_6_products                  
puppet.noarch          3.7.3-1.el6      @puppetlabs_6_products                  
puppetlabs-release.noarch
                       6-11             @puppetlabs_6_products                  
ruby-augeas.x86_64     0.4.1-3.el6      @puppetlabs_6_deps                      
ruby-shadow.x86_64     1:2.2.0-2.el6    @puppetlabs_6_deps                      
rubygem-json.x86_64    1.5.5-3.el6      @puppetlabs_6_deps  

SSL协议

[root@grb16 ~]# yum list installed |grep ssl
nss_compat_ossl.x86_64 0.9.6-1.el6      @anaconda-CentOS-201410241409.x86_64/6.6
openssl.x86_64         1.0.1e-30.el6_6.4
openssl-devel.x86_64   1.0.1e-30.el6_6.4
[root@grb16 ~]# 

在各种服务器上安装的SSL和Puppet程序包之间未发现差异。尚未停用或重新安装的系统仍可以运行Puppet。该问题仅限于重新安装的服务器。请注意,Puppet尚未在其他两台重新安装的服务器上运行。是什么导致此问题以及如何解决?


1
恩 您已撤销证书,但CRL尚未更新。您是否还发行了新证书?
猎鹿人2014年

如果我正确理解了该过程,则在puppet agent -t我在客户端上运行的第一个证书上,它会创建证书并将其发送给puppetmaster进行批准,因此,如果这是颁发新证书的正确方法,那么我会这样做。
Itai Ganot 2014年

@ItaiGanot确实,但是有时驻留在代理上的/ var / lib / puppet / ssl中的某些旧证书或过时的证书存在冲突
030 2014年

我遇到了相同的错误味精。要检查的另一件事是第二个请求是否显示与节点相同的fqdn。该请求显示p主的fqdn。
客人

Answers:


20

简洁的答案

问题CRL is not yet valid for表明,Puppet代理与Puppetmaster之间的时间不同步。同步时间(NTP)。还要从Puppet-agent和Puppetmaster中删除证书,然后在代理上运行Puppet。


综合答案

CRL is not yet valid for 驻留在以下代码段中。

下面的测试代码片段说明是什么原因导致的问题:

it 'includes the CRL issuer in the verify error message' do
  crl = OpenSSL::X509::CRL.new
  crl.issuer = OpenSSL::X509::Name.new([['CN','Puppet CA: puppetmaster.example.com']])
  crl.last_update = Time.now + 24 * 60 * 60
  ssl_context.stubs(:current_crl).returns(crl)

  subject.call(false, ssl_context)
  expect(subject.verify_errors).to eq(["CRL is not yet valid for /CN=Puppet CA: puppetmaster.example.com"])
end

ssl_context

let(:ssl_context) do
  mock('OpenSSL::X509::StoreContext')
end

学科

subject do
  described_class.new(ssl_configuration,
  ssl_host)
end

该代码包括OpenSSL :: X509 :: CRL类的摘录。

发行人=(p1)

               static VALUE
ossl_x509crl_set_issuer(VALUE self, VALUE issuer)
{
    X509_CRL *crl;

    GetX509CRL(self, crl);

    if (!X509_CRL_set_issuer_name(crl, GetX509NamePtr(issuer))) { /* DUPs name */
        ossl_raise(eX509CRLError, NULL);
    }
    return issuer;
}

last_update = {p1)

               static VALUE
ossl_x509crl_set_last_update(VALUE self, VALUE time)
{
    X509_CRL *crl;
    time_t sec;

    sec = time_to_time_t(time);
    GetX509CRL(self, crl);
    if (!X509_time_adj(crl->crl->lastUpdate, 0, &sec)) {
        ossl_raise(eX509CRLError, NULL);
    }

    return time;
}

LAST_UPDATED时间将是当前时间加上一个额外的一天,将被传递到调用的主题函数调用函数驻留在default_validator类

class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
  attr_reader :peer_certs
  attr_reader :verify_errors
  attr_reader :ssl_configuration

  FIVE_MINUTES_AS_SECONDS = 5 * 60

  def initialize(
    ssl_configuration = Puppet::SSL::Configuration.new(
    Puppet[:localcacert], {
      :ca_auth_file => Puppet[:ssl_client_ca_auth]
    }),

    ssl_host = Puppet::SSL::Host.localhost)
    reset!
    @ssl_configuration = ssl_configuration
    @ssl_host = ssl_host
  end

  def call(preverify_ok, store_context)
    if preverify_ok
      ...
    else
      ...
      crl = store_context.current_crl
      if crl
        if crl.last_update && crl.last_update < Time.now + FIVE_MINUTES_AS_SECONDS
          ...
        else
          @verify_errors << "#{error_string} for #{crl.issuer}"
        end
        ...
      end
    end
  end

如果preverify_ok为false,则else子句适用。由于if crl.last_update && crl.last_update < Time.now + FIVE_MINUTES_AS_SECONDS错误的时间加上了另一天,因此结果为false,否则else语句将适用。对@verify_errors << "#{error_string} for #{crl.issuer}"结果的评价CRL is not yet valid for /CN=Puppet CA: puppetmaster.example.com

为了解决问题:

  1. 在Puppet代理和Puppetmaster之间同步时间。NTP服务器是否在两个节点上都运行(正常)?
  2. 从代理中删除或重命名完整的ssl文件夹(/ var / lib / puppet / ssl)。
  3. 通过颁发证书来撤消主证书 sudo puppet cert clean <fqdn-puppet-agent>
  4. 如果禁用了自动签名,则对证书进行签名
  5. 在代理上运行人偶

总之,应该始终同步Puppet-agent和Puppetmaster上的时间。超过5分钟的最大允许偏差会导致此问题。


我仍然得到此信息:“ [root @ grb16〜]#puppet agent -t信息:grb16.company.com的缓存证书信息:ca的证书certificate_revocation_list错误:无法请求证书:SSL_connect返回= 1 errno = 0状态= SSLv3读取服务器证书B:证书验证失败:[CRL尚未对/ CN = Puppet CA:foreman.company.com有效]正在退出;无法检索证书并且已禁用
waitforcert

@ItaiGanot好的。/ var / lib / puppet / ssl已删除。证书已从Puppetmaster中删除。您能否检查代理是否连接到正确的puppetmaster?
2014年

它确实:[root @ grb16〜]#grep服务器/etc/puppet/puppet.conf服务器= foreman.company.com
Itai Ganot 2014年

1
你是男人!我很傻,忘了编辑机器的时区。非常感谢!
Itai Ganot 2014年

1
我也有这个问题。原来,我需要在节点上重新启动ntp:systemctl restart ntpd
Red Cricket

2

遇到同样的问题。

我们的人偶设置是使用GitHub进行版本控制的,因此每次我们提供一个新的人偶大师时,都会遇到证书问题。通常puppet ca --clean --all可以正常工作,但我们发现以下更可靠的方法:

rm -rf $(puppet master --configprint ssldir)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.