Skip to content

Commit 608f19d

Browse files
resolving pr comment and removed unused function
1 parent 3330e4e commit 608f19d

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

lib/AuthenticationSDK/util/MLEUtility.rb

+2-29
Original file line numberDiff line numberDiff line change
@@ -70,39 +70,12 @@ def self.encrypt_request_payload(merchant_config, request_payload)
7070
end
7171
end
7272

73-
74-
def self.get_certificate(merchant_config, log_obj)
75-
begin
76-
p12_file_path = File.join(merchant_config.keysDirectory, merchant_config.keyFilename + '.p12')
77-
file = File.binread(p12_file_path)
78-
p12_file = OpenSSL::PKCS12.new(file, merchant_config.keyPass)
79-
x5_cert_pem = OpenSSL::X509::Certificate.new(p12_file.certificate)
80-
x5_cert_pem.subject.to_a.each do |attribute|
81-
return x5_cert_pem if attribute[1].include?(merchant_config.mleKeyAlias)
82-
end
83-
p12_file.ca_certs.each do |cert|
84-
cert.subject.to_a.each do |attribute|
85-
return cert if attribute[1].include?(merchant_config.mleKeyAlias)
86-
end
87-
end
88-
rescue OpenSSL::PKCS12::PKCS12Error => e
89-
log_obj.logger.error("Failed to load PKCS12 file: #{e.message}")
90-
raise e
91-
rescue OpenSSL::X509::CertificateError => e
92-
log_obj.logger.error("Failed to create X509 certificate: #{e.message}")
93-
raise e
94-
rescue StandardError => e
95-
log_obj.logger.error("An error occurred while getting the certificate: #{e.message}")
96-
raise e
97-
end
98-
end
99-
10073
def self.validate_certificate(certificate, mle_key_alias, log_obj)
10174
if certificate.not_after.nil?
10275
log_obj.logger.warn("Certificate for MLE don't have expiry date.")
103-
end
104-
if certificate.not_after < Time.now
76+
elsif certificate.not_after < Time.now
10577
log_obj.logger.warn('Certificate with MLE alias ' + mle_key_alias + ' is expired as of ' + certificate.not_after.to_s + ". Please update p12 file.")
78+
# raise StandardError.new('Certificate required for MLE has been expired on : ' + certificate.not_after.to_s)
10679
else
10780
time_to_expire = certificate.not_after - Time.now
10881
if time_to_expire < Constants::CERTIFICATE_EXPIRY_DATE_WARNING_DAYS * 24 * 60 * 60

0 commit comments

Comments
 (0)