Class: Rpush::Client::ActiveModel::CertificatePrivateKeyValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Rpush::Client::ActiveModel::CertificatePrivateKeyValidator
- Defined in:
- lib/rpush/client/active_model/certificate_private_key_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rpush/client/active_model/certificate_private_key_validator.rb', line 5 def validate(record) if record.certificate.present? begin x509 = OpenSSL::X509::Certificate.new(record.certificate) pkey = OpenSSL::PKey::RSA.new(record.certificate, record.password) x509 && pkey rescue OpenSSL::OpenSSLError record.errors.add :certificate, 'value must contain a certificate and a private key.' end end end |