Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows service serviceCredentials Invalid hexadecimal string format

I'm debugging Win service. I have added some certificates on server. Trying to find certificate by its serial number. https://gyazo.com/9cdcda75e98fe7b7c35496976a5aaaeb

The piece of behaviors.config:

  <serviceCredentials>
    <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="DDBS.DDBSPasswordValidator, DDBS" />
    <serviceCertificate findValue="‎1C5411F9D38252824C2EC1CC7E5EBE3F" x509FindType="FindBySerialNumber" storeLocation="LocalMachine" storeName="My" />
  </serviceCredentials>

I got error: Service cannot be started. System.FormatException: Invalid hexadecimal string format.

like image 992
Vyacheslav Avatar asked Dec 25 '15 12:12

Vyacheslav


2 Answers

Remove all the findValue="XXXXXXX" and after that write it again.. sometimes the invalid char is after findValue="??? <--- here

like image 199
Xtremexploit Avatar answered Oct 09 '22 21:10

Xtremexploit


From Jan Angelovič on MSDN Forum:

If you cut and paste the [Serial Number or Thumbprint] from the common certificate dialog, it is copied in UNICODE (UTF-16LE) encoding with special invisible control characters (0xFF and 0xFE aka “Byte order mark“) on the beginning of the string.

Personally, I saw this with the thumbprint; cut & paste from the dialog into Visual Studio kept 2 non-displayed characters (that could be "stepped through" with the cursor and deleted).

like image 25
richaux Avatar answered Oct 09 '22 21:10

richaux