    # File lib/fog/aws/requests/iam/upload_server_certificate.rb, line 46
            def upload_server_certificate(certificate, private_key, name, options = {})
              if certificate.nil? || certificate.empty? || private_key.nil? || private_key.empty?
                raise Fog::AWS::IAM::ValidationError.new
              end
              response = Excon::Response.new

              # Validate cert and key
              begin
                # must be an RSA private key
                raise OpenSSL::PKey::RSAError unless private_key =~ /BEGIN RSA PRIVATE KEY/

                cert = OpenSSL::X509::Certificate.new(certificate)
                chain = OpenSSL::X509::Certificate.new(options['CertificateChain']) if options['CertificateChain']
                key = OpenSSL::PKey::RSA.new(private_key)
              rescue OpenSSL::X509::CertificateError, OpenSSL::PKey::RSAError => e
                message = if e.is_a?(OpenSSL::X509::CertificateError)
                            "Invalid Public Key Certificate."
                          else
                            "Invalid Private Key."
                          end
                raise Fog::AWS::IAM::MalformedCertificate.new(message)
              end

              unless cert.check_private_key(key)
                raise Fog::AWS::IAM::KeyPairMismatch.new
              end

              if self.data[:server_certificates][name]
                raise Fog::AWS::IAM::EntityAlreadyExists.new
              else
                response.status = 200
                path = options['Path'] || "/"
                data = {
                  'Arn' => Fog::AWS::Mock.arn('iam', self.data[:owner_id], "server-certificate/#{name}"),
                  'Path' => path,
                  'ServerCertificateId' => Fog::AWS::IAM::Mock.server_certificate_id,
                  'ServerCertificateName' => name,
                  'UploadDate' => Time.now
                }
                self.data[:server_certificates][name] = data
                response.body = {
                  'Certificate' => data,
                  'RequestId' => Fog::AWS::Mock.request_id
                }
              end

              response
            end