Esempio n. 1
0
        /// <summary>
        /// Loads Certificate from the given file path.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="filePath">The path of certificate file to be loaded.</param>
        /// <returns>Loaded certificate class instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// The filePath should not be null
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Invalid certificate file format. Provided file path does not exist or
        /// cannot be accessed.
        /// </exception>
        static public Certificate Load(string filePath)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException("filepath should not be null");
            }

            IntPtr ptr = IntPtr.Zero;

            Interop.CheckNThrowException(
                CkmcTypes.LoadCertFromFile(filePath, out ptr),
                "Failed to load Certificate: " + filePath);

            return(new Certificate(ptr));
        }
Esempio n. 2
0
        // Refresh handle(IntPtr) always. Because C# layer
        // properties(Binary, Format) could be changed.
        internal IntPtr GetHandle()
        {
            IntPtr ptr = IntPtr.Zero;

            try
            {
                CheckNThrowException(
                    CkmcTypes.CertNew(
                        this.Binary, (UIntPtr)this.Binary.Length, (int)this.Format,
                        out ptr),
                    "Failed to create cert");

                return(ptr);
            }
            catch
            {
                if (ptr != IntPtr.Zero)
                {
                    CkmcTypes.CertFree(ptr);
                }

                throw;
            }
        }