Skip to content

ArgumentError: wrong number of arguments #8

@targetdrone

Description

@targetdrone

I'm getting an error in line 63 of of pkcs8_key.rb in v0.4.0 of keystores:

define_method(:initialize) do |der_or_pem|

I'm trying to add the keystores gem to extract an X.509 certificate from a JKS so I can view its expiration date. After an otherwise successful chef-client run, I am seeing the error shown in this log (which contains the exact contents of the chef-stacktrace.out file). The error appears to occur while attempting to update the chef org with new information from the node:

Running handlers:
[2020-12-31T15:01:00-06:00] ERROR: Running exception handlers
Running handlers complete
[2020-12-31T15:01:00-06:00] ERROR: Exception handlers complete
Chef Infra Client failed. 1 resources updated in 07 seconds
[2020-12-31T15:01:00-06:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2020-12-31T15:01:00-06:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2020-12-31T15:01:00-06:00] DEBUG: ArgumentError: wrong number of arguments (given 2, expected 1)
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/keystores-0.4.0/lib/keystores/jks/pkcs8_key.rb:63:in block in <class:RSA>' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/http/authenticator.rb:95:in new'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/http/authenticator.rb:95:in load_signing_key' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/http/authenticator.rb:42:in initialize'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/http.rb:98:in new' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/http.rb:98:in block in initialize'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/http.rb:97:in each' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/http.rb:97:in initialize'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/server_api.rb:40:in initialize' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/node.rb:104:in new'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/node.rb:104:in chef_server_rest' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/node.rb:647:in save'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/client.rb:575:in save_updated_node' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/client.rb:734:in converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/client.rb:288:in run' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/application.rb:292:in run_with_graceful_exit_option'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/application.rb:268:in block in run_chef_client' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/local_mode.rb:42:in with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/application.rb:251:in run_chef_client' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/application/base.rb:335:in run_application'
/opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-16.0.257/lib/chef/application.rb:68:in run' /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/chef-bin-16.0.257/bin/chef-client:25:in <top (required)>'
/usr/bin/chef-client:171:in load' /usr/bin/chef-client:171:in

'
[2020-12-31T15:01:00-06:00] FATAL: ArgumentError: wrong number of arguments (given 2, expected 1)

From what I can see, according to the chef-16.0.257 source, in authenticator.rb line 95 , the chef code is calling the RSA constructor with two arguments, the second being an empty string containing a blank password. The keystores implementation of RSA has no two-argument constructor.

For reasons I don't know enough Ruby to undertstand, it looks like it's using keystores' overload of the OpenSSL class, instead of using the OpenSSL class directly. The error stopped when I removed the keystores gem from my recipe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions