PKISolutions / PSPKI

PowerShell PKI Module
Microsoft Public License
389 stars 59 forks source link

Fix: Submit-CertificateRequest #187

Closed karthikeyanrathore closed 1 year ago

karthikeyanrathore commented 1 year ago
CCertRequest::Submit: The format of the specified domain name is invalid. 0x800704bc (WIN32: 1212 \\r\\nERROR_INVALID_DOMAINNAME)\\r\\nAt C:\\\\Program Files\\\\WindowsPowerShell\\\\Modules\\\\PSPKI\\\\3.7.2\\\\Client\\\\Submit-CertificateRequest.ps1:71 char:5\\r\\n+ ...             $Status = $CertRequest.Submit(0xff,$Request,$strAttribute ...\\r\\n+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\r\\n    + CategoryInfo          : OperationStopped: (:) [], COMException\\r\\n    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException\\r\\n \\r\\n')"
Crypt32 commented 1 year ago

Can you provide more details?

karthikeyanrathore commented 1 year ago

Yea, Basically i have a powershell script and a python flask script which runs the powershell script. The flask script is hosted on the IIS server. The powershell script is to just submit certificate request. This works locally on windows but when i host it on the ISS server it fails ? do you know, what might be the issue?

Crypt32 commented 1 year ago

This is still vague description. What is ISS server? What PS commands you execute (exact syntax)? Can you provide your request file?

karthikeyanrathore commented 1 year ago

I think this issue is not related to PSPKI its something to do wth certsrv. I'm looking into it.

karthikeyanrathore commented 1 year ago

Hi @Crypt32 coundn't find the solution to the problem.

PS cmd:

$ca = Connect-CertificationAuthority;
$csr_path = $args[0];
Submit-CertificateRequest -Path "$csr_path" -CA $ca -Attribute "CertificateTemplate:WebServer" ;

CSR:

-----BEGIN CERTIFICATE REQUEST-----
MIIEnjCCAoYCAQAwWTELMAkGA1UEBhMCeHgxCzAJBgNVBAgMAnh4MQswCQYDVQQH
DAJ4eDELMAkGA1UECgwCeHgxDTALBgNVBAsMBFRlc3QxFDASBgNVBAMMC3BzcGtp
X2NoZWNrMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA6l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KSQT3M5BF2wLgBa9ihJFw4HLPYaZY0ECgPh5S
8OUbdfUww8B+4lakpkyzb0Oax/XfoOyWfx6usRmFhUUF4Am+1fILJtBcRMe8NdRk
fPNNEwhtoR0vCmFEDguAxsfw9q7l+8zhs17gt8ntV8KWcBFeaqi0tq0Ti5jDeeyb
HPdu/04tBkLzfwtFsp3zIbdhcOd9mFDnhbqXjZjVkMIrd7wCzRu6PVQ1AQohrfg+
4caWWUl44+psY5iyM4vJjU47kmkgW68Fka0ZtelbT5St7k9NnNi5gFS5WrRa8kCk
RsqYGTbAaaM7aLf3P8q1regPwh0+I8EYxFySOLtSkJFWQg==
-----END CERTIFICATE REQUEST-----

ISS is a program provided by windows to host applications. In order to host to python/flask apps this is the only way to do it.

The problem is when i run the server locally (inside the windows server) and test PS cmd, it works successfully. but then when i do the same operation using windows DNS server ip address (hosted on ISS sever) it shows:

'Exception: CCertRequest::Submit: The format of the specified domain name is invalid. 0x800704bc (WIN32: 1212 \\r\\nERROR_INVALID_DOMAINNAME)\\r\\nAt C:\\\\Program 

Files\\\\WindowsPowerShell\\\\Modules\\\\PSPKI\\\\3.7.2\\\\Client\\\\Submit-CertificateRequest.ps1:71 char:5\\r\\n+ ...             $Status = $CertRequest.Submit(0xff,$Request,$strAttribute ...\\r\\n+                 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\r\\n    + CategoryInfo          : OperationStopped: (:) [], COMException\\r\\n    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException\\r\\n \\r\\n')"

Is there any specific requirements you know that must be specified or should be correct before submitting CSR.

-- > problem --> CertRequest.Submit --> https://github.com/PKISolutions/PSPKI/blob/master/PSPKI/Client/Submit-CertificateRequest.ps1#L71

Thanks.

Crypt32 commented 1 year ago

ISS is a program provided by windows to host applications

then it is IIS, not ISS.

but then when i do the same operation using windows DNS server ip address

what does it mean? Where you use IP address?

karthikeyanrathore commented 1 year ago

I have a windows instance / Server running on AWS. Inside the Server there is IIS application which helps me host my flask server and from my local machine i access the API (flask application) using Public DNS of windows instance provided by AWS. Does this make sense ?

karthikeyanrathore commented 1 year ago

I think the issue is with this IIS application. But i m not able to debug this error:

CCertRequest::Submit: The format of the specified domain name is invalid
karthikeyanrathore commented 1 year ago

Ahh, Sorry for the trouble, the issue was with IIS Manager. Had to make changes in the Application Pool.

If above solution is not working maybe try this: https://stackoverflow.com/questions/36050230/code-works-on-local-machine-but-not-on-iis