class AWS::IAM::SigningCertificate

Signing certificates can be activated and deactivated. By default, newly-uploaded certifictes are active.

certificate = iam.signing_certificates.upload(cert_body)
certificate.status
#=> :active

certificate.deactivate!
certificate.active?
#=> false

Contents

You can access the certificate contents you uploaded:

> puts certificate.contents
-----BEGIN CERTIFICATE-----
MIICdzCCAeCgAwIBAgIFGS4fY6owDQYJKoZIhvcNAQEFBQAwUzELMAkGA1UEBhMC
......
Glli79yh87PRi0vNDlFEoHXNynkvC/c4TiWruZ4haM9BR9EdWr1DBNNu73ui093K
F9TbdXSWdgMl7E0=
-----END CERTIFICATE-----

User

A certificate can also return the user it belongs to. If the certificate belongs to the AWS account, then {user} will return nil.

user = iam.users['someuser'].signing_certificates.first
user.name
#=> 'someuser'

@attr_reader [String] contents Returns the contents of this

signing certificate.

@attr_reader [Symbol] status The status of this signing

certificate.  Status may be +:active+ or +:inactive+.

Attributes

id[R]

@return [String] Returns the signing certificate’s ID.

user[R]

@return [User,nil] Returns the user this cerficiate belongs to.

Returns +nil+ if the cerficiate is a root credential for the 
account.  If the configured credentials belong to an IAM user, 
then that user is the implied owner.

Public Class Methods

new(certificate_id, options = {}) click to toggle source

@param [String] certificate_id The id of the signing certificate. @param [Hash] options @param [User] :user The user this signing certificate belongs to.

# File lib/aws/iam/signing_certificate.rb, line 59
def initialize certificate_id, options = {}
  @id = certificate_id
  @user = options[:user]
  @user ? super(@user, options) : super(options)
end

Public Instance Methods

activate!() click to toggle source

Activates this signing cerificate.

@example

signing_certificate.activate!
signing_certificate.status
# => :active

@return [nil]

# File lib/aws/iam/signing_certificate.rb, line 116
def activate!
  self.status = 'Active'
  nil
end
active?() click to toggle source

@return [Boolean] Returns true if this signing certificate is active.

# File lib/aws/iam/signing_certificate.rb, line 99
def active?
  status == :active
end
deactivate!() click to toggle source

Deactivates this signing cerificate.

@example

signing_certificate.deactivate!
signing_certificate.status
# => :inactive

@return [nil]

# File lib/aws/iam/signing_certificate.rb, line 129
def deactivate!
  self.status = 'Inactive'
  nil
end
delete() click to toggle source

Deletes the signing certificate.

# File lib/aws/iam/signing_certificate.rb, line 135
def delete
  client.delete_signing_certificate(resource_options)
  nil
end
inactive?() click to toggle source

@return [Boolean] Returns true if this signing certificate is inactive.

# File lib/aws/iam/signing_certificate.rb, line 104
def inactive?
  status == :inactive
end
user_name() click to toggle source

@return [String,nil] Returns the name of the user this certificate

belogns to.  If the certificate belongs to the account, +nil+ is
returned.
# File lib/aws/iam/signing_certificate.rb, line 94
def user_name
  @user ? @user.name : nil
end

Protected Instance Methods

get_resource(attribute) click to toggle source

IAM does not provide a request for “get signing certificate”.

Also note, we do not page the response. This is because restrictions on how many certificates an account / user may have is fewer than one page of results. @private

# File lib/aws/iam/signing_certificate.rb, line 155
def get_resource attribute
  options = user ? { :user_name => user.name } : {}
  client.list_signing_certificates(options)
end
matches_response_object?(obj) click to toggle source

@private

# File lib/aws/iam/signing_certificate.rb, line 162
def matches_response_object? obj
  user_name = obj.respond_to?(:user_name) ? obj.user_name : nil
  obj.certificate_id == self.id and user_name == self.user_name
end
resource_identifiers() click to toggle source

@private

# File lib/aws/iam/signing_certificate.rb, line 142
def resource_identifiers
  identifiers = []
  identifiers << [:certificate_id, id]
  identifiers << [:user_name, user.name] if user
  identifiers
end