Compartilhar via


Update (PUT/MERGE) Certificates

Update using the HTTP PUT/MERGE operation.

Code Examples

Request

Method Request URI HTTP Version

MERGE

HTTPS://<HOST>:<PORT>/00000000-0000-0000-0000-000000000000/Certificates(guid'<GUID>')

HTTP/1.1

Request URI Parameters

URI Parameter Description

GUID

Required. The unique identifier value (CertificateID) for a Certificate entity.

Request URI Example

Example URI

MERGE https://sma-server:9090/00000000-0000-0000-0000-000000000000/Certificates(guid'd5db8755-c6d8-43c1-bdff-df0cc632b1df') HTTP/1.1

Request Headers

For more information about the common request headers used by this operation, see Standard Service Management Automation POST/GET/PUT/DELETE Headers.

Request Body

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="https://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="https://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <id>https://sma-server:9090/00000000-0000-0000-0000-000000000000/Certificates(guid'd5db8755-c6d8-43c1-bdff-df0cc632b1df')</id>
  <category term="Orchestrator.ResourceModel.Certificate" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <title />
  <updated>2014-04-15T20:34:52Z</updated>
  <author>
    <name />
  </author>
  <content type="application/xml">
    <m:properties>
      <d:CertificateID m:type="Edm.Guid">d5db8755-c6d8-43c1-bdff-df0cc632b1df</d:CertificateID>
      <d:CreationTime m:type="Edm.DateTime">2014-04-15T20:04:14.933</d:CreationTime>
      <d:Description>Certificate description v2</d:Description>
      <d:ExpiryTime m:type="Edm.DateTime">2039-12-31T15:59:59</d:ExpiryTime>
      <d:LastModifiedTime m:type="Edm.DateTime">2014-04-15T20:04:14.933</d:LastModifiedTime>
      <d:Name>Test Certificate</d:Name>
      <d:RawValue>IAAAAAEAAADLAQAAMIIBxzCCAXGgAwIBAgIQ6HiYt4ogwYtOIAaaaYqd1jANBgkqhkiG9w0BAQQFADAWMRQwEgYDVQQDEwtSb290IEFnZW5jeTAeFw0wMzA0MDUxOTUwMTlaFw0zOTEyMzEyMzU5NTlaMCIxIDAeBgNVBAMTF0pvZSdzLVNvZnR3YXJlLUVtcG9yaXVtMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkwfHx50UjZSiTTozk0zzYXcrrbj7qlO/hXX8UGbbllfDB5+noDrSTl2Mdtrwwf80Oy6VbaDnPz3iNUG+VDM4tcVrLbHNMjSrk5Ndg8rK6EeWVHuYE7PUlgLTPU/2W4idPIFvUUv5IOa8q6SxD5Twt+xbsGz4afanH18J95xwVHQIDAQABo0swSTBHBgNVHQEEQDA+gBAS5AktBh0dTwCNYSHcFmRjoRgwFjEUMBIGA1UEAxMLUm9vdCBBZ2VuY3mCEAY3bACqAGSKEc+41KpcNfQwDQYJKoZIhvcNAQEEBQADQQBqbAerWZcQboC8qxwAPVoJz3Raee8hiyt4eQYETACAMDn5Io6u6nUpvzd6CFSKcFZ9pWjTdBlzm8Lm/qHDmQ3u</d:RawValue>
      <d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
      <d:Thumbprint>8044E2A478067D4F8867BB57A11006C1799A611D</d:Thumbprint>
      <d:Value>MsaVHj0uWRV6bLGpBl8lraF5JzTzSalI9F0rAwIJqt/6yNgRZ2cciHxlkA0aGC0+V3fiXu+no/Ts5DJnxjAY6SWaivjXmqViSc8I/BYNwi3l5qjeEp0F7izsNfDj4okr+r2Yp3joOltW78Zpz9z3FYr5DFSLe03keeOy0CeyP2rAJx/Cj6R+opiyGOVjfYmm3BdkXDWlAeS0SeKCdSPKPm3ssXu88Td3VJIGA5ROqQ5/whLfwpvv2kiQiyV4Dz91Hv2tErMO0TQZDnGIpRKojR0PjMl/Q7J1I43CcSQfACu5NNRiBrWQiIxV5BA9RIWlTa26Ykrt5NinsOhuy80GRATR3pdBYGNTkMEyflnHzAB8BhMA1s3puqPjAViIhghMUwQhi5TVTa03F54WBfNeyqWM4jTJOaf+Ji7PI9HfI25mgyiVSXTgbcovs6SjuLg9R8+/ROTLzodWGqT4VTCWnJ2JJ/W0FzMelayDYtIgMBxVwpwPzkJRMYpq0EYE+MlJa8bQncgFeLbCgr2PWx5IQOr0jQTWTNPpTj1x7jFu3I44tjdxjgFH6TlZtakw1HbZK3AbUrvhm+y+KIDyoXGXWhB3S7SX02MTmqzGwXEKjn5aFFymA8ws0Ux1MXgoLxcastCDTx2pSmf3m3ZHqx/J1KnsvRXIwB5rSmsrw0T60YX4qcxj87CfsRQuSxLPWk2kgO4Ct2XnKjMDj/lK5mzbDEr3d1QK8Sze+nxqfq46+XqQSnLHYXbP9JBTyNQKv6gDvU+pEOT8ZxHEGkxgoHxbfS4f883gSQFwjM93YLSR8HRsF057pj6pMwrQBajbLaAeO550JshTHPN/OmAy3/VSlQ==</d:Value>
    </m:properties>
  </content>
</entry>

Response

Response Codes

Response Code Description

HTTP/1.1 204 No Content

Request fulfilled.

Response Headers

For more information about the common response headers used by this operation, see Standard Service Management Automation POST/GET/PUT/DELETE Headers.

Response Body

The PUT/MERGE operation has no response body.

Code Examples

The following example searches for a specific Certificate, identified by the CertificateID (a unique guid), and updates a value.

namespace CodeSample.Microsoft.SystemCenter.SMA
{
    public class SMASamples
    {
        public static void Main()
        {
            // Replace this with the name of your SMA web service endpoint.
            string serviceEndPoint = "https://sma-server:9090/00000000-0000-0000-0000-000000000000";

            // Setup the connection to SMA
            OrchestratorApi SMAService = new OrchestratorApi(new Uri(serviceEndPoint));

            // Set credentials to the default or to a specific user.
            ((DataServiceContext)SMAService).Credentials = CredentialCache.DefaultCredentials;
            //((DataServiceContext)SMAService).Credentials = new NetworkCredential("user", "pwd", "domain");
            
            try
            {
                // Identify a specific certificate instance to search for.
                var certificateID = new Guid("d5db8755-c6d8-43c1-bdff-df0cc632b1df");

                // Query for the specific certificate instance identified by CertificateID.
                var certificate = SMAService.Certificates.Where(r => r.CertificateID == certificateID).FirstOrDefault();

                // Initialize variables to specify new certificate values = path and password are required to instantiate the x509 certificate instance.
                string certificatePath = "c:\\sma\\certs\\fabrikam.cer";
                string certificatePassword = "password";  // SecureString password
                string certificateDescription = "Certificate description v2";

                // Create a x509 certificate instance to work with.
                var x509Certificate = new X509Certificate2(certificatePath, certificatePassword, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);

                // Modify certificate instance properties.
                certificate.RawValue = Convert.ToBase64String(x509Certificate.Export(X509ContentType.SerializedCert, certificatePassword));
                certificate.Thumbprint = x509Certificate.Thumbprint;
                certificate.Description = certificateDescription;

                // Update the certificate object.
                // Note: This action is queued up until the SaveChanges action is called.
                SMAService.UpdateObject(certificate);

                // Save all pending actions (client -> server communication initiated).
                SMAService.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("An error occurred during execution.", ex);
            }
        }
    }
}

See Also

Concepts

Certificate
Certificates