Giter Site home page Giter Site logo

Comments (5)

dmilov avatar dmilov commented on August 17, 2024 1

Good one. We can create an SRS Client PS Module and update the API pester tests to use it. I'll prepare the scaffold, feel free to put all the content there.

from script-runtime-service-for-vsphere.

dmilov avatar dmilov commented on August 17, 2024 1

Added the module manifest

https://github.com/vmware/script-runtime-service-for-vsphere/tree/master/client-sdk/powershell

@lucdekens Feel free to add content in there.
https://github.com/vmware/script-runtime-service-for-vsphere/blob/master/test/api-integration-tests/tests/SRSAPIHelpers.ps1 could help.

from script-runtime-service-for-vsphere.

dmilov avatar dmilov commented on August 17, 2024 1

Let's start with PS 7 initially, later we can add support for 5.1

from script-runtime-service-for-vsphere.

lucdekens avatar lucdekens commented on August 17, 2024

Thanks for the pointer to SRSAPIHelpers.ps1.

Question: shall the module support PSv5.1?

If yes, we have to foresee an alternative for the SkipCertificateCheck switch when invoked from PSv5.1.
Something similar to what I did in my Invoke-SrsMethod function in my A Hitchhikers Guide To SRS 1.0.0

from script-runtime-service-for-vsphere.

dmilov avatar dmilov commented on August 17, 2024

As a SkipCertificateCheck solution for PS 5.1 I can suggest a wrapper function like

function Invoke-RestMethodEx {
param(
# InvokeRestMethodParams,

[switch]
$SkipCertificateCheck

)

    if (-not("SkipCertificateCheck" -as [type])) {
        Add-Type -TypeDefinition `
                ("using System;" + `
                "using System.Net;" + `
                "using System.Net.Security;" + `
                "using System.Security.Cryptography.X509Certificates;" + `
                "public static class SkipCertificateCheck {" + `
                    "public static bool ReturnTrue(object sender," + `
                        "X509Certificate certificate," + `
                        "X509Chain chain," + `
                        "SslPolicyErrors sslPolicyErrors) { return true; }" + `
                    "public static RemoteCertificateValidationCallback GetDelegate() {" + `
                        "return new RemoteCertificateValidationCallback(SkipCertificateCheck.ReturnTrue);" + `
                    "}" + `
                "}")
    }

    if ($SkipCertificateCheck) {
        [System.Net.ServicePointManager]::ServerCertificateValidationCallback += [SkipCertificateCheck]::GetDelegate()
    }

    Invoke-RestMethod https://10.23.82.191/api/about

   if ($SkipCertificateCheck) {
     # back to previous value, for the sake of example I assume it was $null
       [System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null
   }

}

from script-runtime-service-for-vsphere.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.