Class: Crypto::RSAKey
- Inherits:
-
OpenSSL::PKey::RSA
- Object
- OpenSSL::PKey::RSA
- Crypto::RSAKey
- Defined in:
- lib/crypto/rsa_key.rb
Overview
Clase para crear llaves privadas, en formato X509 no PKCS7
Para convertirlos vía linea de comandos:
openssl pkcs8 -inform DER -in nombreGiganteDelSAT.key -passin pass:miFIELCreo >> certX509.pem
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#enc_path ⇒ Object
readonly
path de la llave .pem.enc.
-
#enc_pem ⇒ Object
readonly
información de la llave en formato .pem.enc.
-
#password ⇒ Object
readonly
contraseña de la llave.
-
#path ⇒ Object
readonly
path de la llave.
-
#pem ⇒ Object
readonly
información de la llave en formato .pem.
Instance Method Summary collapse
-
#encrypt_pem(encrypt_password) ⇒ Object
Encripta el pem generado, requerido para cancelar facturas.
-
#initialize(file, password = nil) ⇒ Security::RSAKey
constructor
Crea una llave privada.
-
#seal(text) ⇒ Object
Sella una cadena de texto.
Constructor Details
#initialize(file, password = nil) ⇒ Security::RSAKey
Crea una llave privada
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/crypto/rsa_key.rb', line 33 def initialize(file, password = nil) @password = password if File.file?(file) @path = file @enc_path = @path + '.enc' file = File.read(@path) end super file, password @data = to_s.gsub(/^-.+/, '').delete("\n") end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
23 24 25 |
# File 'lib/crypto/rsa_key.rb', line 23 def data @data end |
#enc_path ⇒ Object (readonly)
path de la llave .pem.enc
13 14 15 |
# File 'lib/crypto/rsa_key.rb', line 13 def enc_path @enc_path end |
#enc_pem ⇒ Object (readonly)
información de la llave en formato .pem.enc
22 23 24 |
# File 'lib/crypto/rsa_key.rb', line 22 def enc_pem @enc_pem end |
#password ⇒ Object (readonly)
contraseña de la llave
16 17 18 |
# File 'lib/crypto/rsa_key.rb', line 16 def password @password end |
#path ⇒ Object (readonly)
path de la llave
10 11 12 |
# File 'lib/crypto/rsa_key.rb', line 10 def path @path end |
#pem ⇒ Object (readonly)
información de la llave en formato .pem
19 20 21 |
# File 'lib/crypto/rsa_key.rb', line 19 def pem @pem end |
Instance Method Details
#encrypt_pem(encrypt_password) ⇒ Object
Encripta el pem generado, requerido para cancelar facturas
56 57 58 59 |
# File 'lib/crypto/rsa_key.rb', line 56 def encrypt_pem(encrypt_password) cipher = OpenSSL::Cipher::Cipher.new('des3') return to_pem(cipher, encrypt_password) end |
#seal(text) ⇒ Object
Sella una cadena de texto
51 52 53 |
# File 'lib/crypto/rsa_key.rb', line 51 def seal(text) Base64.encode64(sign(OpenSSL::Digest::SHA256.new, text)).delete("\n") end |