# A question: how to get the already existed registration secret

**URL:** <https://discourse.chef.io/t/a-question-how-to-get-the-already-existed-registration-secret/1306>\
**Category:** Chef Infra (archive)\
**Created:** [October 21, 2009, 10:41pm UTC](https://discourse.chef.io/t/a-question-how-to-get-the-already-existed-registration-secret/1306 "2009-10-21T22:41:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dikang\_Gu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dikang_gu/32/911_2.png) [@Dikang\_Gu](https://discourse.chef.io/u/Dikang_Gu)\
**Post date:** [October 21, 2009, 10:41pm UTC](https://discourse.chef.io/t/a-question-how-to-get-the-already-existed-registration-secret/1306/1 "2009-10-21T22:41:46Z")

</div>

Hello folks,

I have a question about the following code (in chef/lib/chef/client.rb):  
def register  
determine\_node\_name unless @node\_name  
Chef::Log.debug(“Registering #{@safe\_name} for an openid”)

```
  begin
    if @rest.get_rest("registrations/#{@safe_name}")
      @secret = Chef::FileCache.load(File.join("registration",

```

@safe\_name))  
end  
rescue Net::HTTPServerException =\> e  
case e.message  
when /^404/  
create\_registration  
else  
raise  
end  
rescue Chef::Exceptions::FileNotFound  
Chef::Application.fatal! “A remote registration already exists for  
#{@safe\_name}, however the local shared secret does not exist.” +  
" To remedy this, you could delete the registration via  
webUI/REST, change the node\_name option in config.rb" +  
" (or use the -N/–node-name option to the CLI) or" +  
" copy the old shared secret to #{File.join(Chef::Config[  
:file\_cache\_path], ‘registration’, @safe\_name)}", 3  
end

```
  true
end

```

def authenticate  
determine\_node\_name unless @node\_name  
Chef::Log.debug(“Authenticating #{@safe\_name} via openid”)  
response = @rest.post\_rest(‘openid/consumer/start’, {  
“openid\_identifier” =\> “#{Chef::Config[:openid\_url]}  
/openid/server/node/#{@safe\_name}”,  
“submit” =\> “Verify”  
})  
@rest.post\_rest(  
"#{Chef::Config[:openid\_url]}#{response[“action”]}",  
{ “password” =\> @secret }  
)  
end

If the registration already exists, that is, we will get the secret from the  
line “@secret = Chef::FileCache.load(File.join(“registration”, @safe\_name))”,  
but this is the one after the encryption, right? And then, in the  
authenticate function, we should post the secret unencrypted to the openid  
server, right? How do you solve this problem?

Thanks  
Dikang
