summaryrefslogtreecommitdiff
path: root/spec/unit/ssl/certificate_factory_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-02-05(PUP-1409) add authorityKeyIdentifier to client certificatesjrussek1-4/+12
As discussed in the ticket this will add the authorityKeyIdentifier that is not required, but recommended to add to certs signed by a CA conforming to RFC 5280. This extension takes the subjectKeyIdentifier of the CA certificate and adds it as keyid to authorityKeyIdentifier. This PR also adds a test to make sure the extension is correctly added to the resulting certificate.
2014-01-24(PUP-1387) fixes wrong hash in subjectKeyIdentifierjrussek1-0/+7
this fixes the regression that appeared when the arguments to ExtensionFactory where accidentally swapped. Also added a test case to check if the subjectKeyIdentifier is present.
2013-11-19(#23200) allow certificate factory to add custom extsAdrien Thebo1-0/+18
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-09-06(#7962) Added settings class for handling time intervals.Steven Lindberg1-6/+15
The DurationSetting converts strings with units into a number of seconds, but more importantly guarantees that the setting will be an integer. The following settings can now be specified as durations: configtimeout filetimeout waitforcert splaylimit runinterval rrdinterval ca_ttl Since multiple settings can use this format, the description was removed from `ca_ttl` to be added to the config section of puppet-docs. Also note, since many of these settings specify sub-hour times, the unit 'm' was added for specifying times in minutes.
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
Without this patch some spec files are using `ruby -S rspec` and others are using `rspec`. We should standardize on a single form of the interpreter used for spec files. `ruby -S rspec` is the best choice because it correctly informs editors such as Vim with Syntastic that the file is a Ruby file rather than an Rspec file.
2012-01-15(Maint) Fix time-dependent certificate factory test failuresJosh Cooper1-3/+3
Some of the certificate factory spec tests were trying to ensure that the certificate factory's ttl was being applied when signing a certificate's `not_after` time. However, the tests did not take into account the amount of time it takes to sign the certificate, which can be non-negligible. As a result, the absolute difference between `not_after` and `Time.now + ttl` was somtimes greater than or equal to 1 second, causing sporadic test failures. This commit changes the tests to be less time dependent by ensuring the difference is within 30 seconds (for both `not_before` and `not_after)
2011-10-21Ruby 1.8.5 compatibility changes in tests and code.Daniel Pittman1-5/+4
A handful of methods, like Array#count and String#start_with? don't exist in older versions of Ruby, and have sufficiently complex semantics that rebuilding them seems less than worthwhile. This rewrites the small points of code to avoid those methods, retaining compatibility with 1.8.5 and 1.8.6 across the board. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-10-21(#2848) Eliminate redundant `master_dns_alt_names`.Daniel Pittman1-3/+3
Now that `dns_alt_names` applies to local CSR generation, there is no need for a special configuration option only applied to a master certificate. Eliminating that option allows us to simplify the overall model, and provide more uniform access to the `subjectAltName` setting when required. Documentation about the option is also updated. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-10-21(#2848) rename subject-alt-name option to dns-alt-namesDaniel Pittman1-2/+2
The name of the option for adding subjectAltName fields to the request didn't really indicate what it actually did: we forced the names into the DNS label space, and generally imposed a bunch of additional behaviours. This renames the option to better match the intended use. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-10-21(#2848) Rename `certdnsnames` to match new behaviour.Daniel Pittman1-3/+3
As part of the update to SSL the behaviour of the `certdnsnames` options changed sufficiently that it would be terribly confusing to retain it. Instead, modify the setting to warn that it is ignored, and add a new setting to set the default subjectAltName value for bootstrapping a master certificate. This retains the one really useful part of the feature, without the risk that someone will accidentally use the old name and receive a nasty surprise. It should also draw more attention to formerly insecure configurations. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-10-21(#2848) CSR subjectAltNames handling while signing.Nick Lewis1-9/+10
The puppet cert application now supports the --allow-subject-alt-names command line flag to specify that the certificate to sign should contain a subjectAltName extension request. If the option is not specified, an attempt to sign a certificate with alt names will fail. Similarly, if the option is specified, an attempt to sign a certificate without alt names will fail. The latter behavior is deliberate, and is intended to help stop users from developing a habit of always supplying the option, and thus accidentally signing a dangerous certificate without realizing it when one comes along. It also adds the `--subject-alt-name` option that will add a `subjectAltName` extension request to a CSR when it is generated. This allows an additional service to be bootstrapped with those names. Generally only one of the two options should be required, as the CSR and the signing process are distinct. Mostly by Nick Lewis, additional code by Daniel Pittman Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-10-21(#2848) Rewrite SSL Certificate Factory, fixing `subjectAltName` leak.Daniel Pittman1-70/+90
This is a major rewrite of the SSL CertificateFactory, which transforms the way that we build the certificate we are about to sign in response to a CSR. The main body of rework is to clean up the code and make it easier to manage and validate, but there are two essential changes: 1. We no longer inject `subjectAltName` from local `certdnsnames` configuration option into every certificate we generate. This fixes CVE-2011-3872, and prevents issuing client certificates that can impersonate the master. 2. *All* request extensions from the CSR are transported into the final certificate. This includes `basicConstraints`; we rely on other layers of the Puppet stack having validated the code to this point. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-2/+1
We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2010-12-06maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson1-1/+1
Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe
2010-07-09Code smell: Two space indentationMarkus Roberts1-75/+75
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
2010-06-28[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rbMarkus Roberts1-0/+107
Part 2 re-did the change on the spec files, which it shouldn't have.
2010-06-28[#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts1-107/+0
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
2010-06-23[#3994] rename the specs to have _spec.rb at the endMarkus Roberts1-0/+107
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700