1

I have copied an existing Sitecore/Coveo setup from the test environment to my local machine. How do I change the Coveo for Sitecore configuration like Search API Url, Application Secret Key, Admin Service Configuration etc

Changing directly on the config files is enough? I think this also would be stored somewhere on the DB right? what is the right way of doing it?

2 Answers 2

3

If you are using a recent version of Coveo for Sitecore you may be able to change some config values by using the Coveo Command-Center. For other config values such as the SearchAPI URL, you will need to update the config file directly.

Most of the configurations you want to change will be under App_Config/Include/Coveo/Coveo.CloudPlatformClient.Custom.config and App_Config/Include/Coveo/Coveo.SearchProvider.Custom.config.

If you are trying to bring the configurations you have from one environment to another, just make sure you are copying every Coveo config file under both App_Config/Include/Coveo and App_Config/Modules/Coveo folders.

Among all Coveo configuration values, there is one that is more sensible when doing this. I'm talking about the <sitecorePassword> you can find in the Coveo.SearchProvider.Custom.config file. This value is stored encrypted and the encryption key is not in any configuration file.

That's why besides copying the config files you should also make sure you have the CORE_ENCRYPTIONKEYS (or ENCRYPTIONKEYS if not using SC 9.x) entry on your core database (or WEB_ENCRYPTIONKEYS in the web if you don't have core as part of your setup).

1
  • Hi , Hugo Thanks for your reply . I am using Sitecore 8.1 with Coveo 4 on premise. My biggest worry is any changes in my local version (copied ) shouldn't affect actual the original version .Thanks!
    – user3621
    Jul 22, 2020 at 18:26
0

To add onto that, if you navigate to the Properties table in the Web DB, you will find an entry (if this is coveo for Sitecore 10+, not sure about lower versions) with Key=WEB_ENCRYPTIONKEYS. I did some digging on the encryption method Coveo uses and came up with a handy decryptor in case you need it

void Main()
{
    const string encryptedPassword = "";
    const string secret = "";

    var keys = GetKeys(secret);
    var deccryptedPasswordBytes = DecryptData(encryptedPassword, keys);

    var decrpyptedPassword = "";
    using(var stream = new MemoryStream(deccryptedPasswordBytes)) 
    {
        using(var reader = new StreamReader(stream))
        {
            decrpyptedPassword = reader.ReadToEnd();
        }       
    }

    decrpyptedPassword.Dump();
}

public byte[] Decode(string p_EncodedValue)
{
    return Convert.FromBase64String(p_EncodedValue);
}

public IEncryptionKeys GetKeys(string value)
{
    byte[] byteArray = Decode(value);

    byte[] numArray1 = new byte[32];
    byte[] numArray2 = new byte[16];
    
    using(var readStream = new MemoryStream(byteArray))
    {
        readStream.Read(numArray1, 0, numArray1.Length);
        readStream.Read(numArray2, 0, numArray2.Length);
    }
    
     return (IEncryptionKeys) new RijndaelEncryptionKeys(numArray1, numArray2);
}

public byte[] DecryptData(string password, IEncryptionKeys keys)
{
    byte[] passArray = Decode(password);
    
    using (Rijndael rijndael = Rijndael.Create())
    {
        rijndael.Key = keys.Key;
        rijndael.IV = keys.InitialisationVector;
        ICryptoTransform decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV);
        using (MemoryStream memoryStream = new MemoryStream(passArray))
        {
            using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, decryptor, CryptoStreamMode.Read))
            {
                using (MemoryStream destination = new MemoryStream())
                {
                    cryptoStream.CopyTo((Stream)destination);
                    return destination.ToArray();
                }
            }
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.