Opening spartacus in smartedit giving Uncaught Error in browser console - sap-commerce-cloud

When trying to open Spartacus in smartedit, I am getting the below error:-
Uncaught Error:
Allowed whitelist characters are a-z, A-Z, 0-9, -, period, or *
The wildcard * can be used to represent a prefixed domain, Good example: .domain.com:80
but not a suffix or port, Bad examples: subdomain..com subdomain.domain.com:*.
Every whitelisting must contain a specific port.
at webApplicationInjector.js:15
at Array.map (<anonymous>)
at Function.t.convertWhitelistingToRegexp (webApplicationInjector.js:15)
at Object.<anonymous> (webApplicationInjector.js:4)
at n (webApplicationInjector.js:4)
at webApplicationInjector.js:4
at webApplicationInjector.js:4

Check the value of data-smartedit-allow-origin. It needs to have a port. localhost:80 will work; localhost will not work. Adjust the port accordingly. If it's running on HTTPS, then it needs to be 443 or some other custom value.
You may also need to adjust the domain. e.g. stackoverflow.com:443

Related

Python requests module SSLError(CertificateError("hostname 'x.x.x.x' doesn't match 'x.x.x.x")))

I'm using the "requests" module for getting JSON from my web service, using the next code:
import requests
import SSL
# With or without this line of code below, the output is the same
ssl.match_hostname = lambda cert, hostname: True
response = requests.get("MY_URL", cert=("client.pem", "client-key.pem"), verify="CAcert.cer")
When the SSL step seems to fail with the following message:
HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: {WEBSERVICE_URL_PATTERN} (Caused by SSLError(CertificateError("hostname 'x.x.x.x' doesn't match 'x.x.x.x'")))
I'm using Python 3.10.5 with the latest version of the "requests" module.
Does anyone know what could cause this kind of error and how to fix it?
I assume you've redacted actual names which are in fact different, because if you really did have a host named x.x.x.x using a cert with the same name it would match (unless it wasn't really the same because the CA, or a potentially-bogus 'subject'/'subscriber', used lookalike characters).
From the documentation of match_hostname
Changed in version 3.7: The function is no longer used to TLS connections. Hostname matching is now performed by OpenSSL. ...
Deprecated since version 3.7.
At the python.ssl level, or http.client or urllib.requests, you can still turn off only hostname checking with check_hostname=False in the SSLContext. However AFAIK requests doesn't give you access to the SSL level except for setting the cert(s) as you do or the sledgehammer option of turning off all verification with verify=False.
If at all possible, you should try to use a hostname and a host cert that do match. Note changing either the name you request or the cert can accomplish this.
The problem was solved, using a Subject Alternative Name (SAN) for the server, with a value of its own IP address.
I've found out that we use Simple-CA, and the request of getting a signed certificate from it was with a Common Name (CN), when we don't have a domain name.
After changing the signing action to SAN instead of CN, the problem was solved.
Thanks for the helpers!

Could not find Host of Azure In App SQL Database

I've created a MySQL In App database for my Azure App, and got the connection string for it. This string is injected into the application.json, and then used to create the actual connection:
WebApplicationBuilder builder = // get it somewhere
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
builder.Services.AddDbContext<DatabaseContext>(options => options.UseMySQL(connectionString));
Only... no connection string works. The one with the port (Database=localdb;Data Source=127.0.0.1:53844;User Id=azure;Password=password) throws:
System.Net.Sockets.SocketException (11001): No such host is known.
And the one without the port (Database=localdb;Data Source=127.0.0.1;User Id=azure;Password=password) throws:
System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
This question sugested another connection string (Server=127.0.0.1; Port=53844; Database=localdb; Uid=azure; Pwd=password), which weirdly enough also throws this exception, even though the port is defined:
System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
And the manual suggests yet another string (server=localhost;database=localdb;user=azure;password=password) which again throws one of the two exceptions depending on if the port is present.
Connecting via the browser works fine, so I can confirm port, username and password work normally.
Just to be sure, I tried "localhost" as the host, too. Same results.
What am I doing wrong?
It's a mix out of all these connection strings:
server=localhost;port=53844;database=localdb;user=azure;password=password
(Port and server separated, but both present.)
Works for me right now.

How do I save an IP address in a variable?

I get this error when I use a host Ip in a server I am trying to set up. This has never happened before.
# Host Credentials
host = '192.068.0.3'
port = '4445'
I am met with this error, right at the .068:
invalid syntax (<unknown>, line 12)pylint(syntax-error)
Really, how can this be? I'm using Visual Studio Code as my text editor.

Tor ControlPort HashPassword

After I generate a hashed password and I try to run my tor-request module and I keep getting error. I have updated the new pass in my torr file, in my script and restarted tor. I still get this error and don't know how to fix. I see it was a commmon bug a few years ago but no soltuion. Thanks
Uncaught Error: Error communicating with Tor ControlPort
515 Authentication failed: Password did not match HashedControlPassword value from configuration. Maybe you tried a plain text password? If so, the standard requires that you put it in double quotes.
torr file
HashedControlPassword 16:142<MoreNumbers>49
Matches my pass generated through command line arg.

Problem with System.Net.Dns.GetHostEntry(dnsServer) on .NET 4.0

I have been using the following code for months (without problem) in a .NET 2.0/3.5 environment:
string server="192.168.1.3";
IPHostEntry ipe = System.Net.Dns.GetHostEntry(server);
IPAddress ipa = ipe.AddressList[0];
IPEndPoint ipep = new IPEndPoint(ipa, (int)UdpServices.Domain);
Here, server is hardcoded to an IP address, but in my application it could potentially be something like "server.test.com".
When converting my project to .NET 4.0, this code stopped working when directly passing an IP address (still works with a hostname). It crashes with this exception:
System.Net.Sockets.SocketException was unhandled
Message=The requested name is valid, but no data of the requested type was found
Source=System
ErrorCode=11004
NativeErrorCode=11004
StackTrace:
at System.Net.Dns.InternalGetHostByAddress(IPAddress address, Boolean includeIPv6)
at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
Because all I need is the resulting IPEndPoint, I can work around the issue by using IPAddress.Parse to generate the IPAddress object, but I want to know if any of you know why this behaviour changed in .NET 4.0? (If we can't resolve the hostname from the IP address, an exception is now thrown).
Microsoft answered this here:
this was purposely changed to more
consistently represent name resolution
failures. If you have input strings
that you just want to convert to
IPAddresses, it is recommended that
you use IPAddress.TryParse or
Dns.GetHostAddresses

Resources