ItProblem is simplethat you set to toCharArray
the length of the String. You copyBut the newlinesecond parameter is the maximum allowed length of the output and there is then no space for the terminating zero and string is cut at last character.
The function toCharArray knows the size of the String. The second parameter should be the size of the char array buffer_ssid.toCharArray(ssid, sizeof(ssid));
And next problem could be that you copy the CR/LF characters from input into ssid and paasswordpassword. You can see it in debug printouts.