GoCD database connection properties question

13 views
Skip to first unread message

Tsanko Stoev

unread,
Nov 21, 2022, 4:21:07 PM11/21/22
to go...@googlegroups.com
Hello All,

I was browsing the GoCD documentation and specifically database connection properties. There is a way to use an encrypted password for the connection (db.encryptedPassword). How does one go about creating an encrypted value from the plain text password?
Thank you in advance.

Sincerely,
Tsanko Stoev

Aravind SV

unread,
Nov 22, 2022, 4:50:15 AM11/22/22
to go...@googlegroups.com
I would say the easiest way would be to add a secure environment variable to any job or pipeline and copy the encrypted value off of the config XML. I vaguely remember a command-line utility for it, but copying it off the config XML is likely simpler at this time.

Cheers,
Aravind

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/CAGWsXCB3gagSK2jcfxkhQB9rJhxT41-UfkXZDZ8HXcvUb6X9tQ%40mail.gmail.com.

Chad Wilson

unread,
Nov 22, 2022, 4:58:28 AM11/22/22
to go...@googlegroups.com
If seeking higher degrees of automation, I believe you can also use the API at https://api.gocd.org/current/#encrypt-a-plain-text-value for this, alongside a personal access token or another credential - but I haven't personally tried it for this purpose.

I am sure Aravind can correct me if this is for a different purpose and encrypts differently. :-)


Aravind SV

unread,
Nov 22, 2022, 5:00:02 AM11/22/22
to go...@googlegroups.com
Oh. Yes, Chad is right. That's a better way. :)

Tsanko Stoev

unread,
Nov 22, 2022, 10:47:49 AM11/22/22
to go...@googlegroups.com
That's the first thing I tried but it seems that the API call is not working or I am doing something wrong as I am getting the following response:
-- START --

HTTP/1.1 404 Not Found
Content-Type: text/plain;charset=utf-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: JSESSIONID=node01g8wiol63q14ljfilz086yxyo570.node0; Path=/go; Expires=Tue, 06-Dec-2022 15:43:28 GMT; Max-Age=1209600; Secure; HttpOnly
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: chrome=1
X-Powered-By: ARR/3.0
X-Powered-By: ASP.NET
Date: Tue, 22 Nov 2022 15:43:27 GMT
Content-Length: 58
Strict-Transport-Security: max-age=31536000; includeSubDomains

The url you are trying to reach appears to be incorrect.

-- END ---

Have you successfully been able to use it?
Thanks.

Tsanko


Aravind SV

unread,
Nov 22, 2022, 2:02:28 PM11/22/22
to go...@googlegroups.com
What is the URL you're using / what's the full call? I've used it before, yes.

Tsanko Stoev

unread,
Nov 22, 2022, 3:52:53 PM11/22/22
to go...@googlegroups.com
I am using https://host/go/api/admin/encrypt
I have tried it in SoapUI and also tried the example with curl. Same results. Give it a try.

Tsanko

Ketan Padegaonkar

unread,
Nov 23, 2022, 5:56:18 AM11/23/22
to go...@googlegroups.com
This works for me:

curl -H 'Authorization: bearer XXXXX' -H 'Accept: application/vnd.go.cd+json' https://build.gocd.org/go/api/admin/encrypt -d '{"value": "badger"}' -H 'Content-Type: application/json'
{
  "_links" : {
    "doc" : {
      "href" : "https://api.gocd.org/23.1.0/#encryption"
    },
    "self" : {
      "href" : "https://build.gocd.org/go/api/admin/encrypt"
    }
  },
  "encrypted_value" : "AES:YYY:ZZZ"
}

- Ketan



Chad Wilson

unread,
Nov 23, 2022, 6:44:34 AM11/23/22
to go...@googlegroups.com
Yeah, as in Ketan's example the Accept header is important. Without that (or set incorrectly) you'll get a 404 - as mentioned at https://api.gocd.org/current/#introduction

-Chad

Tsanko Stoev

unread,
Nov 23, 2022, 2:05:11 PM11/23/22
to go...@googlegroups.com
Thank you all for the help. I think I figured out my issue and I am able to use the API for encryption of text. 

Tsanko

Reply all
Reply to author
Forward
0 new messages