Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplicationConfiguration.SaveToFile() removes "RejectSHA1SignedCertificates" #184 #930

Closed
PrashantDesai opened this issue Mar 26, 2020 · 6 comments
Assignees

Comments

@PrashantDesai
Copy link

OPCFoundation/UA-.NET-Legacy#184

Is this problem is resolved in following Nuget package?? It is not working for me
1.4.360.33

@AlinMoldovean
Copy link
Contributor

Hi @PrashantDesai ,

ApplicationConfiguration.SaveToFile(string filePath) writes in the file only the members that have a value different from the default of the type.
This is because EmitDefaultValue = false for all the members of configuration classes.

        //
        // Summary:
        //     Gets or sets a value that specifies whether to serialize the default value for
        //     a field or property being serialized.
        //
        // Returns:
        //     true if the default value for a member should be generated in the serialization
        //     stream; otherwise, false. The default is true.
        public bool EmitDefaultValue { get; set; }

RejectSHA1SignedCertificates will be written in the file only if its value is "true".

Please note that SaveToFile() produces a slightly different output compared to the initial xml configuration file. e.g it also removes the comments.

@PrashantDesai
Copy link
Author

PrashantDesai commented Mar 30, 2020 via email

@PrashantDesai
Copy link
Author

We are facing exactly present in this link:
https://opcfoundation.org/forum/opc-ua-implementation-stacks-tools-and-samples/applicationconfiguration-savetofile-removes-rejectsha1signedcertificates/#p1824

If we remove RejectSHA1SignedCertificates in XML the following code gives error as present the above link, then if we put back flag again as false it works fine,

            ApplicationConfiguration configuration = ApplicationConfiguration.Load(new System.IO.FileInfo(configurationFile),
                Opc.Ua.ApplicationType.Server, null).Result;

            CertificateValidator validator = new CertificateValidator();
            validator.Update(configuration);
            validator.Validate(certificate);

@PrashantDesai
Copy link
Author

we are using 1.4.360.33 nu get package

@AlinMoldovean
Copy link
Contributor

Hi @PrashantDesai ,

The problem is that you application instance certificate has a SHA1 signature that is not trusted anymore.
If you still want to use it you should do the following:

ApplicationConfiguration configuration = ApplicationConfiguration.Load(new System.IO.FileInfo(configurationFile),
                Opc.Ua.ApplicationType.Server, null).Result;

configuration.SecurityConfiguration.RejectSHA1SignedCertificates = false;

            CertificateValidator validator = new CertificateValidator();
            validator.Update(configuration);
            validator.Validate(certificate);

@PrashantDesai
Copy link
Author

Hello Alin,

Thanks a lot. It is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants